mongoes

package module
v0.0.0-...-82bf724 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2017 License: MIT Imports: 4 Imported by: 0

README

MONGOES

Go Report Card

commandline tools to index mongodb documents in elasticsearch

Installation | Mongoes | Usage | License

This tool is perfect fit for you if you only need to index some collection to elasticsearch without having to setup replicaset, or if you want to have control over the mapping like what fields to be indexed what type in elasticsearch this field should be indexed

Installation

  • git clone
  • go get
  • make

Mongoes

  • Mongoes will index your mongodb collection to elasticsearch based on a mapping you provide

Usage

mongoes --help

NAME:
   mongoes - Index Mongodb Collection to ES

USAGE:
   mongoes [global options] command [command options] [arguments...]

VERSION:
   1.0.0

AUTHOR:
   Adhitya Ramadhanus <[email protected]>

COMMANDS:
     index    Index collection to elasticsearch
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version
  • config, Your configuration file (in json)
  • Config Example
{
    "mongodb": {
        "uri": "localhost:27017",
        "database": "somedb",
        "collection": "somecoll"
    },
    "elasticsearch": {
        "uri": "http://localhost:9200",
        "index": "someindex",
        "type": "sometype"
    },
    "query": {
        "completed": true
    },
	  "mapping": {	
		  "title": { // take title field in mongodb collection
			"es_type": "string", // will be mapped to string
			"es_index": "not_analyzed"
		},
		"completed": {
			"es_name": "done", // will be mapped to field called done in elasticsearch
			"es_type": "boolean"
		}
	}
}

License

MIT © [Adhitya Ramadhanus]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBoolJSON

func GetBoolJSON(obj map[string]interface{}, path string) bool

GetBoolJSON takes a map[string]interface{} and path and return bool Example of path : mongodb.uri Path is a string that contains json keys that's splitted by '.'

func GetConfig

func GetConfig(configPath string, esOptions *ESOptions, mgoOptions *MgoOptions) error

func GetObjectJSON

func GetObjectJSON(obj map[string]interface{}, path string) map[string]interface{}

GetObjectJSON takes a map[string]interface{} and path and return map[string]interface{} Example of path : mongodb.uri Path is a string that contains json keys that's splitted by '.'

func GetStringJSON

func GetStringJSON(obj map[string]interface{}, path string) string

GetStringJSON takes a map[string]interface{} and path and return string Example of path : mongodb.uri Path is a string that contains json keys that's splitted by '.'

func ReadJSONFromFile

func ReadJSONFromFile(path string, v *map[string]interface{}) error

ReadJSONFromFile takes a path and pointer to map[string]interface and return error (if any) Example of path : ../module/test.json

Types

type ESOptions

type ESOptions struct {
	EsIndex      string
	EsType       string
	EsURI        string
	BulkIndexNum int
	EsMapping    map[string]interface{}
}

ESOptions is options struct for elasticsearch, included is index name, type name and URI for ES cluster

type MgoOptions

type MgoOptions struct {
	MgoDbname   string
	MgoCollname string
	MgoURI      string
	MgoQuery    map[string]interface{}
}

MgoOptions is optiosn struct for mongo, included is database name, collection name, and URI for mongo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL