Skip to content

Commit

Permalink
4.0.0 add some destructured url configs to help in some deployment sc…
Browse files Browse the repository at this point in the history
…enarios
  • Loading branch information
ryanramage committed Apr 27, 2018
1 parent 1d4cdfe commit 6a92d72
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ Alternatively, the config file can be in JSON
}
```

You can also destructure some of the urls to help configuration management
```ini
couch=http://localhost:5984
database=idx-edm-v5
elasticsearch=http://elastic-1.com:9200
indexName=idx-edm-v5
indexType=listing
```

### Load documents

To load all the documents into elasticsearch, run
Expand Down
15 changes: 15 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ if (!config.elasticsearch) {
if (config.mapper && typeof config.mapper === 'string') {
config.mapper = require(path.resolve(config.mapper))
}

// allow config.couch to be the root url of the couch and config.database to be just the db name
// config.couch = http://sofa.place.com:5984
// config.database = idx-edm-v5
// join them together to make the complete url
if (config.couch) config.database = config.couch + '/' + config.database

// allow elasticsearch to be the root url of elasticsearch, and indexName be just the index
// and indexType be the type
// config.elasticsearch = http://elastic.place.com:9200
// config.indexName = idx-edm-v5
// config.indexType = listing
// join them together to make the complete url
if (config.indexName && config.indexType) config.elasticsearch = config.elasticsearch + '/' + config.indexName + '/' + config.indexType

var index_name = url.parse(config.elasticsearch).pathname.split('/')[1]
config.seq_url = url.resolve(config.elasticsearch, '/' + index_name + '/_mapping/seq')

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "couch2elastic4sync",
"version": "3.4.6",
"version": "4.0.0",
"description": "Sync couchdb data to elasticsearch.",
"main": "./lib/index.js",
"bin": "./bin/cli.js",
Expand Down

0 comments on commit 6a92d72

Please sign in to comment.