Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Elasticsearch index name to be set from pelias-config #155

Merged
merged 3 commits into from Aug 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion integration/address_matching.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/admin_matching.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/analyzer_peliasAdmin.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/analyzer_peliasHousenumber.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/analyzer_peliasIndexOneEdgeGram.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/analyzer_peliasIndexTwoEdgeGram.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/analyzer_peliasPhrase.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/analyzer_peliasQueryFullToken.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/analyzer_peliasQueryPartialToken.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/analyzer_peliasStreet.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/analyzer_peliasZip.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/autocomplete_abbreviated_street_names.js
@@ -1,4 +1,3 @@

// Tests to ensure no regressions in the way the autocomplete analyzers handle
// synonym expansions and the corresponding matching of those tokens.

Expand Down
1 change: 0 additions & 1 deletion integration/autocomplete_directional_synonym_expansion.js
@@ -1,4 +1,3 @@

// Tests to ensure no regressions in the way the autocomplete analyzers handle
// synonym expansions and the corresponding matching of those tokens.

Expand Down
1 change: 0 additions & 1 deletion integration/autocomplete_street_synonym_expansion.js
@@ -1,4 +1,3 @@

// Tests to ensure no regressions in the way the autocomplete analyzers handle
// synonym expansions and the corresponding matching of those tokens.

Expand Down
1 change: 0 additions & 1 deletion integration/bounding_box.js
@@ -1,4 +1,3 @@

// validate bounding box behaves as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/dynamic_templates.js
@@ -1,4 +1,3 @@

// http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#_dynamic_templates

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/run.js
@@ -1,4 +1,3 @@

var tape = require('tape');
var common = {};

Expand Down
1 change: 0 additions & 1 deletion integration/source_layer_sourceid_filtering.js
@@ -1,4 +1,3 @@

// validate analyzer is behaving as expected

var tape = require('tape'),
Expand Down
1 change: 0 additions & 1 deletion integration/validate.js
@@ -1,4 +1,3 @@

// simply validate that the schema doesn't error when inserted in to
// your local elasticsearch server, useful to sanity check version upgrades.

Expand Down
1 change: 0 additions & 1 deletion mappings/partial/centroid.js
@@ -1,4 +1,3 @@

// @ref: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html
var schema = {
'type': 'geo_point',
Expand Down
1 change: 0 additions & 1 deletion punctuation.js
@@ -1,4 +1,3 @@

// These characters will be removed from ngrams/shingles
// @see: org/apache/lucene/analysis/cn/smart/stopwords.txt

Expand Down
10 changes: 6 additions & 4 deletions scripts/create_index.js
@@ -1,9 +1,11 @@
var config = require('pelias-config').generate().esclient;
var config = require('pelias-config').generate();
var es = require('elasticsearch');
var client = new es.Client(config);
var client = new es.Client(config.esclient);
var schema = require('../schema');

client.indices.create( { index: 'pelias', body: schema }, function( err, res ){
console.log( '[put mapping]', '\t', 'pelias', err || '\t', res );
var indexName = config.schema.indexName;

client.indices.create( { index: indexName, body: schema }, function( err, res ){
console.log( '[put mapping]', '\t', indexName, err || '\t', res );
process.exit( !!err );
});
6 changes: 3 additions & 3 deletions scripts/drop_index.js
Expand Up @@ -11,8 +11,8 @@ if( isForced() ) drop();
else prompt( drop, fail );

function drop(){
client.indices.delete( { index: 'pelias' }, function( err, res ){
console.log( '\n[delete mapping]', '\t', 'pelias', err || '\t', res );
client.indices.delete( { index: config.schema.indexName }, function( err, res ){
console.log( '\n[delete mapping]', '\t', config.schema.indexName, err || '\t', res );
process.exit( !!err );
});
}
Expand All @@ -25,7 +25,7 @@ function warnIfNotLocal() {

function prompt( yes, no ){
warnIfNotLocal();
rl.question( 'Are you sure you want to drop the pelias index and delete ALL records? ', function( answer ){
rl.question( 'Are you sure you want to drop the ' + config.schema.indexName + ' index and delete ALL records? ', function( answer ){
if( !answer.match(/^y(es)?$/i) ) return no();
return yes();
});
Expand Down
6 changes: 3 additions & 3 deletions scripts/output_mapping.js
@@ -1,9 +1,9 @@
var config = require('pelias-config').generate().esclient;
var config = require('pelias-config').generate();
var es = require('elasticsearch');
var client = new es.Client(config);
var client = new es.Client(config.esclient);
var schema = require('../schema');

var _index = ( process.argv.length > 3 ) ? process.argv[3] : 'pelias';
var _index = ( process.argv.length > 3 ) ? process.argv[3] : config.schema.indexName;
var _type = ( process.argv.length > 2 ) ? process.argv[2] : null; // get type from cli args

if( !_type ){
Expand Down
2 changes: 1 addition & 1 deletion scripts/reset_type.js
Expand Up @@ -3,7 +3,7 @@ var es = require('elasticsearch');
var client = new es.Client(config);
var schema = require('../schema');

var _index = ( process.argv.length > 3 ) ? process.argv[3] : 'pelias';
var _index = ( process.argv.length > 3 ) ? process.argv[3] : config.schema.indexName;
var _type = ( process.argv.length > 2 ) ? process.argv[2] : null; // get type from cli args

if( !_type ){
Expand Down
6 changes: 3 additions & 3 deletions scripts/update_settings.js
@@ -1,9 +1,9 @@
var config = require('pelias-config').generate().esclient;
var config = require('pelias-config').generate();
var es = require('elasticsearch');
var client = new es.Client(config);
var client = new es.Client(config.esclient);
var schema = require('../schema');

var _index = 'pelias';
var _index = config.schema.indexName;

// Error: ElasticsearchIllegalArgumentException[can't change the number of shards for an index
if( schema.settings.hasOwnProperty('index') &&
Expand Down
1 change: 0 additions & 1 deletion settings.js
@@ -1,4 +1,3 @@

var Mergeable = require('mergeable');
var peliasConfig = require('pelias-config');
var punctuation = require('./punctuation');
Expand Down
1 change: 0 additions & 1 deletion test/compile.js
@@ -1,4 +1,3 @@

var path = require('path'),
schema = require('../'),
fixture = require('./fixtures/expected.json');
Expand Down
1 change: 0 additions & 1 deletion test/document.js
@@ -1,4 +1,3 @@

var schema = require('../mappings/document');

module.exports.tests = {};
Expand Down
3 changes: 1 addition & 2 deletions test/partial-admin.js
@@ -1,4 +1,3 @@

var schema = require('../mappings/partial/admin');

module.exports.tests = {};
Expand Down Expand Up @@ -52,4 +51,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
};
3 changes: 1 addition & 2 deletions test/partial-hash.js
@@ -1,4 +1,3 @@

var schema = require('../mappings/partial/hash');

module.exports.tests = {};
Expand Down Expand Up @@ -37,4 +36,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
};
1 change: 0 additions & 1 deletion test/partial-literal.js
@@ -1,4 +1,3 @@

var schema = require('../mappings/partial/literal');

module.exports.tests = {};
Expand Down
1 change: 0 additions & 1 deletion test/run.js
@@ -1,4 +1,3 @@

var tape = require('tape'),
diff = require('difflet')({ indent : 2, comment : true });

Expand Down
1 change: 0 additions & 1 deletion test/settings.js
@@ -1,4 +1,3 @@

var path = require('path'),
settings = require('../settings'),
fs = require('fs');
Expand Down