Skip to content

Commit

Permalink
feat(es5): support for elasticsearch 5.x while also maintaining backw…
Browse files Browse the repository at this point in the history
…ards compatibility with 2.x
  • Loading branch information
missinglink committed Sep 28, 2018
1 parent f7445aa commit b6f3d9b
Show file tree
Hide file tree
Showing 32 changed files with 1,797 additions and 1,053 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ matrix:
env:
matrix:
- ES_VERSION=2.4.6
- ES_VERSION=5.6.12
jdk:
- oraclejdk8
install:
- mkdir /tmp/elasticsearch
- wget -O - https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz | tar xz --directory=/tmp/elasticsearch --strip-components=1
- /tmp/elasticsearch/bin/plugin install analysis-icu
- /tmp/elasticsearch/bin/elasticsearch --daemonize --path.data /tmp
- ./scripts/setup_ci.sh
- npm i
script:
- npm run travis
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ $ npm run integration
Download the image and start an elasticsearch docker container:

```bash
$ docker run --rm --name elastic-test -p 9200:9200 pelias/elasticsearch
$ docker run --rm --name elastic-test -p 9200:9200 -e 'discovery.type=single-node' pelias/elasticsearch:5.6.12
```

### Continuous Integration
Expand Down
2 changes: 1 addition & 1 deletion integration/address_matching.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports.tests = {};
module.exports.tests.functional = function(test, common){
test( 'functional', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

// index some docs
Expand Down
2 changes: 1 addition & 1 deletion integration/admin_matching.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports.tests = {};
module.exports.tests.functional = function(test, common){
test( 'functional', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

// index a document with all admin values
Expand Down
10 changes: 5 additions & 5 deletions integration/analyzer_peliasAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports.tests = {};
module.exports.tests.analyze = function(test, common){
test( 'analyze', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasAdmin' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -34,7 +34,7 @@ module.exports.tests.analyze = function(test, common){
module.exports.tests.functional = function(test, common){
test( 'functional', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasAdmin' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down Expand Up @@ -72,7 +72,7 @@ module.exports.tests.functional = function(test, common){
module.exports.tests.synonyms = function(test, common){
test( 'synonyms', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasAdmin' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -99,7 +99,7 @@ module.exports.tests.synonyms = function(test, common){
module.exports.tests.tokenizer = function(test, common){
test( 'tokenizer', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasAdmin' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -125,7 +125,7 @@ module.exports.tests.tokenizer = function(test, common){
module.exports.tests.unicode = function(test, common){
test( 'normalization', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasAdmin' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down
4 changes: 2 additions & 2 deletions integration/analyzer_peliasHousenumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports.tests = {};
module.exports.tests.analyze = function(test, common){
test( 'analyze', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasHousenumber' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -24,7 +24,7 @@ module.exports.tests.analyze = function(test, common){
module.exports.tests.functional = function(test, common){
test( 'functional', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasHousenumber' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down
12 changes: 6 additions & 6 deletions integration/analyzer_peliasIndexOneEdgeGram.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports.tests = {};
module.exports.tests.analyze = function(test, common){
test( 'analyze', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasIndexOneEdgeGram' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down Expand Up @@ -65,7 +65,7 @@ module.exports.tests.analyze = function(test, common){
module.exports.tests.address_suffix_expansions = function(test, common){
test( 'address suffix expansions', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasIndexOneEdgeGram' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down Expand Up @@ -93,7 +93,7 @@ module.exports.tests.address_suffix_expansions = function(test, common){
module.exports.tests.stop_words = function(test, common){
test( 'stop words', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasIndexOneEdgeGram' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -112,7 +112,7 @@ module.exports.tests.stop_words = function(test, common){
module.exports.tests.functional = function(test, common){
test( 'functional', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasIndexOneEdgeGram' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -135,7 +135,7 @@ module.exports.tests.functional = function(test, common){
module.exports.tests.address = function(test, common){
test( 'address', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasIndexOneEdgeGram' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -159,7 +159,7 @@ module.exports.tests.address = function(test, common){
module.exports.tests.unicode = function(test, common){
test( 'normalization', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasIndexOneEdgeGram' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down
64 changes: 31 additions & 33 deletions integration/analyzer_peliasPhrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports.tests = {};
module.exports.tests.analyze = function(test, common){
test( 'analyze', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasPhrase' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down Expand Up @@ -54,7 +54,7 @@ module.exports.tests.analyze = function(test, common){
module.exports.tests.functional = function(test, common){
test( 'functional', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasPhrase' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down Expand Up @@ -97,7 +97,7 @@ module.exports.tests.functional = function(test, common){
module.exports.tests.tokenizer = function(test, common){
test( 'tokenizer', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasPhrase' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -124,7 +124,7 @@ module.exports.tests.tokenizer = function(test, common){
module.exports.tests.slop = function(test, common){
test( 'slop', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasPhrase' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -142,7 +142,7 @@ module.exports.tests.slop = function(test, common){
module.exports.tests.slop_query = function(test, common){
test( 'slop query', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasPhrase' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down Expand Up @@ -179,31 +179,27 @@ module.exports.tests.slop_query = function(test, common){
function buildQuery( i ){
return {
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"match": {
"name.default": {
"query": i
}
}
"bool": {
"must": [
{
"match": {
"name.default": {
"query": i
}
],
"should": [
{
"match": {
"phrase.default": {
"query": i,
"type": "phrase",
"slop": 2
}
}
}
}
],
"should": [
{
"match": {
"phrase.default": {
"query": i,
"type": "phrase",
"slop": 2
}
]
}
}
}
]
}
}
};
Expand All @@ -213,17 +209,18 @@ module.exports.tests.slop_query = function(test, common){
suite.client.search({
index: suite.props.index,
type: 'mytype',
searchType: 'dfs_query_then_fetch',
body: buildQuery('Lake Cayuga')
}, function( err, res ){
t.equal( res.hits.total, 3 );
var hits = res.hits.hits;

t.equal( hits[0]._source.name.default, 'Lake Cayuga' );
t.equal( hits[1]._source.name.default, 'Cayuga Lake' );
t.equal( hits[2]._source.name.default, '7991 Lake Cayuga Dr' );
t.equal( hits[1]._source.name.default, '7991 Lake Cayuga Dr' );
t.equal( hits[2]._source.name.default, 'Cayuga Lake' );

t.true( hits[0]._score > hits[1]._score );
t.true( hits[1]._score > hits[2]._score );
t.true( hits[0]._score >= hits[1]._score );
t.true( hits[1]._score >= hits[2]._score );
done();
});
});
Expand All @@ -236,7 +233,7 @@ module.exports.tests.slop_query = function(test, common){
module.exports.tests.slop = function(test, common){
test( 'slop', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

// index a document
Expand All @@ -257,6 +254,7 @@ module.exports.tests.slop = function(test, common){
suite.client.search({
index: suite.props.index,
type: 'test',
searchType: 'dfs_query_then_fetch',
body: { query: { match: {
'name.default': {
'analyzer': 'peliasPhrase',
Expand All @@ -280,7 +278,7 @@ module.exports.tests.slop = function(test, common){
module.exports.tests.unicode = function(test, common){
test( 'normalization', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasPhrase' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down
16 changes: 8 additions & 8 deletions integration/analyzer_peliasQueryFullToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports.tests = {};
module.exports.tests.analyze = function(test, common){
test( 'analyze', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasQueryFullToken' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down Expand Up @@ -54,7 +54,7 @@ module.exports.tests.analyze = function(test, common){
module.exports.tests.address_suffix_expansions = function(test, common){
test( 'address suffix expansions', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasQueryFullToken' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -74,7 +74,7 @@ module.exports.tests.address_suffix_expansions = function(test, common){
module.exports.tests.stop_words = function(test, common){
test( 'stop words', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasQueryFullToken' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -89,7 +89,7 @@ module.exports.tests.stop_words = function(test, common){
module.exports.tests.functional = function(test, common){
test( 'functional', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasQueryFullToken' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -112,7 +112,7 @@ module.exports.tests.functional = function(test, common){
module.exports.tests.tokenizer = function(test, common){
test( 'tokenizer', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasQueryFullToken' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -135,7 +135,7 @@ module.exports.tests.tokenizer = function(test, common){
module.exports.tests.slop = function(test, common){
test( 'slop', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

// index a document
Expand Down Expand Up @@ -178,7 +178,7 @@ module.exports.tests.slop = function(test, common){
module.exports.tests.address = function(test, common){
test( 'address', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasQueryFullToken' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand All @@ -202,7 +202,7 @@ module.exports.tests.address = function(test, common){
module.exports.tests.unicode = function(test, common){
test( 'normalization', function(t){

var suite = new elastictest.Suite( null, { schema: schema } );
var suite = new elastictest.Suite( common.clientOpts, { schema: schema } );
var assertAnalysis = analyze.bind( null, suite, t, 'peliasQueryFullToken' );
suite.action( function( done ){ setTimeout( done, 500 ); }); // wait for es to bring some shards up

Expand Down
Loading

0 comments on commit b6f3d9b

Please sign in to comment.