From dd5215cbaec6ae2959701fb5c9d7b51abdb04aaf Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 10 May 2016 14:03:16 +0200 Subject: [PATCH 01/14] upgrade to ES2+ --- package.json | 4 ++-- query/autocomplete_defaults.js | 2 -- query/reverse_defaults.js | 2 -- query/search_defaults.js | 2 -- test/unit/fixture/reverse_boundary_circle.js | 3 +-- test/unit/fixture/reverse_null_island.js | 1 - test/unit/fixture/reverse_standard.js | 1 - test/unit/fixture/reverse_with_boundary_country.js | 1 - test/unit/fixture/reverse_with_source_filtering.js | 1 - test/unit/fixture/search_linguistic_bbox.js | 1 - test/unit/fixture/search_linguistic_focus_bbox.js | 1 - 11 files changed, 3 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 26ba7808..67bbab7a 100644 --- a/package.json +++ b/package.json @@ -51,10 +51,10 @@ "lodash": "^4.5.0", "markdown": "0.5.0", "morgan": "1.7.0", - "pelias-config": "^1.0.1", + "pelias-config": "git://github.com/pelias/config.git#elasticsearch2", "pelias-logger": "^0.0.8", "pelias-model": "^4.0.0", - "pelias-query": "6.3.0", + "pelias-query": "git://github.com/pelias/query.git#elasticsearch2", "pelias-suggester-pipeline": "2.0.4", "pelias-text-analyzer": "^1.0.1", "stats-lite": "1.0.3", diff --git a/query/autocomplete_defaults.js b/query/autocomplete_defaults.js index 08e33aeb..7233a436 100644 --- a/query/autocomplete_defaults.js +++ b/query/autocomplete_defaults.js @@ -15,10 +15,8 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'boundary:circle:radius': '50km', 'boundary:circle:distance_type': 'plane', 'boundary:circle:optimize_bbox': 'indexed', - 'boundary:circle:_cache': true, 'boundary:rect:type': 'indexed', - 'boundary:rect:_cache': true, 'ngram:analyzer': 'peliasQueryPartialToken', 'ngram:field': 'name.default', diff --git a/query/reverse_defaults.js b/query/reverse_defaults.js index 06ad6400..203b37bd 100644 --- a/query/reverse_defaults.js +++ b/query/reverse_defaults.js @@ -15,10 +15,8 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'boundary:circle:radius': '500km', 'boundary:circle:distance_type': 'plane', 'boundary:circle:optimize_bbox': 'indexed', - 'boundary:circle:_cache': true, 'boundary:rect:type': 'indexed', - 'boundary:rect:_cache': true, 'ngram:analyzer': 'peliasQueryPartialToken', 'ngram:field': 'name.default', diff --git a/query/search_defaults.js b/query/search_defaults.js index 0ffdd79f..9d220d4c 100644 --- a/query/search_defaults.js +++ b/query/search_defaults.js @@ -15,10 +15,8 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'boundary:circle:radius': '50km', 'boundary:circle:distance_type': 'plane', 'boundary:circle:optimize_bbox': 'indexed', - 'boundary:circle:_cache': true, 'boundary:rect:type': 'indexed', - 'boundary:rect:_cache': true, 'ngram:analyzer': 'peliasIndexOneEdgeGram', 'ngram:field': 'name.default', diff --git a/test/unit/fixture/reverse_boundary_circle.js b/test/unit/fixture/reverse_boundary_circle.js index 897f019f..4fc728a2 100644 --- a/test/unit/fixture/reverse_boundary_circle.js +++ b/test/unit/fixture/reverse_boundary_circle.js @@ -14,7 +14,6 @@ module.exports = { 'distance': vs.distance, 'distance_type': 'plane', 'optimize_bbox': 'indexed', - '_cache': true, 'center_point': { 'lat': 29.49136, 'lon': -82.50622 @@ -41,4 +40,4 @@ module.exports = { ], 'size': vs.size, 'track_scores': true -}; \ No newline at end of file +}; diff --git a/test/unit/fixture/reverse_null_island.js b/test/unit/fixture/reverse_null_island.js index 5f020ad2..9620b36a 100644 --- a/test/unit/fixture/reverse_null_island.js +++ b/test/unit/fixture/reverse_null_island.js @@ -16,7 +16,6 @@ module.exports = { 'distance': '500km', 'distance_type': 'plane', 'optimize_bbox': 'indexed', - '_cache': true, 'center_point': { 'lat': 0, 'lon': 0 diff --git a/test/unit/fixture/reverse_standard.js b/test/unit/fixture/reverse_standard.js index d0b0b734..adab3ef4 100644 --- a/test/unit/fixture/reverse_standard.js +++ b/test/unit/fixture/reverse_standard.js @@ -16,7 +16,6 @@ module.exports = { 'distance': '500km', 'distance_type': 'plane', 'optimize_bbox': 'indexed', - '_cache': true, 'center_point': { 'lat': 29.49136, 'lon': -82.50622 diff --git a/test/unit/fixture/reverse_with_boundary_country.js b/test/unit/fixture/reverse_with_boundary_country.js index 789cadaf..c63b4ccc 100644 --- a/test/unit/fixture/reverse_with_boundary_country.js +++ b/test/unit/fixture/reverse_with_boundary_country.js @@ -25,7 +25,6 @@ module.exports = { 'distance': '500km', 'distance_type': 'plane', 'optimize_bbox': 'indexed', - '_cache': true, 'center_point': { 'lat': 29.49136, 'lon': -82.50622 diff --git a/test/unit/fixture/reverse_with_source_filtering.js b/test/unit/fixture/reverse_with_source_filtering.js index 28fce18b..e81c98ef 100644 --- a/test/unit/fixture/reverse_with_source_filtering.js +++ b/test/unit/fixture/reverse_with_source_filtering.js @@ -16,7 +16,6 @@ module.exports = { 'distance': '500km', 'distance_type': 'plane', 'optimize_bbox': 'indexed', - '_cache': true, 'center_point': { 'lat': 29.49136, 'lon': -82.50622 diff --git a/test/unit/fixture/search_linguistic_bbox.js b/test/unit/fixture/search_linguistic_bbox.js index 6afe7be6..a672eb15 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -86,7 +86,6 @@ module.exports = { 'bottom': 47.47, 'left': -103.16 }, - '_cache': true, 'type': 'indexed' } }] diff --git a/test/unit/fixture/search_linguistic_focus_bbox.js b/test/unit/fixture/search_linguistic_focus_bbox.js index d5042c0f..b9785532 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -116,7 +116,6 @@ module.exports = { 'bottom': 47.47, 'left': -103.16 }, - '_cache': true, 'type': 'indexed' } }] From cb67dd58d80a3398c042261c9a5741034573b182 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 10 May 2016 17:06:12 +0200 Subject: [PATCH 02/14] refactor boolean query filtering as per: https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_20_query_dsl_changes.html#_literal_filtered_literal_query_and_literal_query_literal_filter_deprecated --- .../autocomplete_linguistic_final_token.js | 114 ++++---- .../fixture/autocomplete_linguistic_focus.js | 172 ++++++----- ...tocomplete_linguistic_focus_null_island.js | 172 ++++++----- ...autocomplete_linguistic_multiple_tokens.js | 138 +++++---- .../fixture/autocomplete_linguistic_only.js | 102 ++++--- .../autocomplete_linguistic_with_admin.js | 274 +++++++++--------- .../autocomplete_single_character_street.js | 268 +++++++++-------- .../autocomplete_with_source_filtering.js | 112 ++++--- test/unit/fixture/reverse_null_island.js | 33 +-- test/unit/fixture/reverse_standard.js | 33 +-- .../fixture/reverse_with_boundary_country.js | 48 ++- .../fixture/reverse_with_source_filtering.js | 43 ++- test/unit/fixture/search_boundary_country.js | 144 +++++---- test/unit/fixture/search_full_address.js | 224 +++++++------- test/unit/fixture/search_linguistic_bbox.js | 144 +++++---- test/unit/fixture/search_linguistic_focus.js | 176 ++++++----- .../fixture/search_linguistic_focus_bbox.js | 198 ++++++------- .../search_linguistic_focus_null_island.js | 176 ++++++----- test/unit/fixture/search_linguistic_only.js | 120 ++++---- .../fixture/search_linguistic_viewport.js | 188 ++++++------ test/unit/fixture/search_partial_address.js | 160 +++++----- test/unit/fixture/search_regions_address.js | 192 ++++++------ .../fixture/search_with_source_filtering.js | 132 ++++----- test/unit/query/reverse.js | 10 +- test/unit/query/search.js | 4 +- 25 files changed, 1622 insertions(+), 1755 deletions(-) diff --git a/test/unit/fixture/autocomplete_linguistic_final_token.js b/test/unit/fixture/autocomplete_linguistic_final_token.js index b4cc33d2..b5f72a37 100644 --- a/test/unit/fixture/autocomplete_linguistic_final_token.js +++ b/test/unit/fixture/autocomplete_linguistic_final_token.js @@ -1,77 +1,73 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'boost': 1, + 'slop': 3, + 'query': 'one', + 'type': 'phrase' + } + } + }], + 'should':[{ + 'match': { + 'phrase.default': { + 'analyzer': 'peliasPhrase', + 'boost': 1, + 'slop': 3, + 'query': 'one', + 'type': 'phrase' + } + } + },{ + 'function_score': { + 'query': { 'match': { 'name.default': { 'analyzer': 'peliasQueryFullToken', - 'boost': 1, - 'slop': 3, 'query': 'one', - 'type': 'phrase' } } - }], - 'should':[{ + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { 'match': { - 'phrase.default': { - 'analyzer': 'peliasPhrase', - 'boost': 1, - 'slop': 3, + 'name.default': { + 'analyzer': 'peliasQueryFullToken', 'query': 'one', - 'type': 'phrase' } } - },{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one', - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one', - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 3 - }] - } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 3 }] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/autocomplete_linguistic_focus.js b/test/unit/fixture/autocomplete_linguistic_focus.js index 430d43c9..7543eabd 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus.js +++ b/test/unit/fixture/autocomplete_linguistic_focus.js @@ -1,10 +1,21 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryPartialToken', + 'boost': 100, + 'query': 'test', + 'type': 'phrase', + 'operator': 'and' + } + } + }], + 'should': [{ + 'function_score': { + 'query': { 'match': { 'name.default': { 'analyzer': 'peliasQueryPartialToken', @@ -14,98 +25,83 @@ module.exports = { 'operator': 'and' } } - }], - 'should': [{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, - 'query': 'test', - 'type': 'phrase', - 'operator': 'and' - } - } - }, - 'functions': [{ - 'linear': { - 'center_point': { - 'origin': { - 'lat': 29.49136, - 'lon': -82.50622 - }, - 'offset': '0km', - 'scale': '250km', - 'decay': 0.5 - } + }, + 'functions': [{ + 'linear': { + 'center_point': { + 'origin': { + 'lat': 29.49136, + 'lon': -82.50622 }, - 'weight': 40 - }], - 'score_mode': 'avg', - 'boost_mode': 'multiply', - 'filter': { - 'or': [ - { - 'term': { - 'layer': 'venue' - } - }, - { - 'term': { - 'layer': 'address' - } - } - ] + 'offset': '0km', + 'scale': '250km', + 'decay': 0.5 } - } - },{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } + }, + 'weight': 40 + }], + 'score_mode': 'avg', + 'boost_mode': 'multiply', + 'filter': { + 'or': [ + { + 'term': { + 'layer': 'venue' } }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } + { + 'term': { + 'layer': 'address' } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 3 - }] + } + ] + } + } + },{ + 'function_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'query': 'test', + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'query': 'test', + } } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 3 }] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js index 9a4afc05..bafa8673 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js +++ b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js @@ -1,10 +1,21 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryPartialToken', + 'boost': 100, + 'query': 'test', + 'type': 'phrase', + 'operator': 'and' + } + } + }], + 'should': [{ + 'function_score': { + 'query': { 'match': { 'name.default': { 'analyzer': 'peliasQueryPartialToken', @@ -14,98 +25,83 @@ module.exports = { 'operator': 'and' } } - }], - 'should': [{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, - 'query': 'test', - 'type': 'phrase', - 'operator': 'and' - } - } - }, - 'functions': [{ - 'linear': { - 'center_point': { - 'origin': { - 'lat': 0, - 'lon': 0 - }, - 'offset': '0km', - 'scale': '250km', - 'decay': 0.5 - } + }, + 'functions': [{ + 'linear': { + 'center_point': { + 'origin': { + 'lat': 0, + 'lon': 0 }, - 'weight': 40 - }], - 'score_mode': 'avg', - 'boost_mode': 'multiply', - 'filter': { - 'or': [ - { - 'term': { - 'layer': 'venue' - } - }, - { - 'term': { - 'layer': 'address' - } - } - ] + 'offset': '0km', + 'scale': '250km', + 'decay': 0.5 } - } - },{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } + }, + 'weight': 40 + }], + 'score_mode': 'avg', + 'boost_mode': 'multiply', + 'filter': { + 'or': [ + { + 'term': { + 'layer': 'venue' } }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } + { + 'term': { + 'layer': 'address' } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 3 - }] + } + ] + } + } + },{ + 'function_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'query': 'test', + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'query': 'test', + } } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 3 }] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js b/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js index d0465b04..17d3f064 100644 --- a/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js +++ b/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js @@ -1,90 +1,86 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'type': 'phrase', + 'boost': 1, + 'slop': 3, + 'query': 'one two' + } + } + }, + { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryPartialToken', + 'boost': 100, + 'query': 'three', + 'type': 'phrase', + 'operator': 'and' + } + } + }], + 'should':[ + { + 'match': { + 'phrase.default': { + 'analyzer' : 'peliasPhrase', + 'type' : 'phrase', + 'boost' : 1, + 'slop' : 3, + 'query' : 'one two' + } + } + }, + { + 'function_score': { + 'query': { 'match': { 'name.default': { 'analyzer': 'peliasQueryFullToken', - 'type': 'phrase', - 'boost': 1, - 'slop': 3, - 'query': 'one two' + 'query': 'one two three', } } }, - { + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, - 'query': 'three', - 'type': 'phrase', - 'operator': 'and' + 'analyzer': 'peliasQueryFullToken', + 'query': 'one two three', } } - }], - 'should':[ - { - 'match': { - 'phrase.default': { - 'analyzer' : 'peliasPhrase', - 'type' : 'phrase', - 'boost' : 1, - 'slop' : 3, - 'query' : 'one two' - } - } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 }, - { - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one two three', - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one two three', - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 3 - }] - } + 'weight': 3 }] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/autocomplete_linguistic_only.js b/test/unit/fixture/autocomplete_linguistic_only.js index 4360f4d7..7ff675d9 100644 --- a/test/unit/fixture/autocomplete_linguistic_only.js +++ b/test/unit/fixture/autocomplete_linguistic_only.js @@ -1,67 +1,63 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryPartialToken', + 'boost': 100, + 'query': 'test', + 'type': 'phrase', + 'operator': 'and' + } + } + }], + 'should':[{ + 'function_score': { + 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'test', - 'type': 'phrase', - 'operator': 'and' } } - }], - 'should':[{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 3 - }] + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'query': 'test', + } } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 3 }] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/autocomplete_linguistic_with_admin.js b/test/unit/fixture/autocomplete_linguistic_with_admin.js index 7cb51eea..c5839e0f 100644 --- a/test/unit/fixture/autocomplete_linguistic_with_admin.js +++ b/test/unit/fixture/autocomplete_linguistic_with_admin.js @@ -1,159 +1,155 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [ - { + 'bool': { + 'must': [ + { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'type': 'phrase', + 'boost': 1, + 'slop': 3, + 'query': 'one two' + } + } + } + ], + 'should': [ + { + 'match': { + 'parent.country': { + 'analyzer': 'peliasAdmin', + 'boost': 800, + 'query': 'three' + } + } + }, + { + 'match': { + 'parent.region': { + 'analyzer': 'peliasAdmin', + 'boost': 600, + 'query': 'three' + } + } + }, + { + 'match': { + 'parent.region_a': { + 'analyzer': 'peliasAdmin', + 'boost': 600, + 'query': 'three' + } + } + }, + { + 'match': { + 'parent.county': { + 'analyzer': 'peliasAdmin', + 'boost': 400, + 'query': 'three' + } + } + }, + { + 'match': { + 'parent.borough': { + 'analyzer': 'peliasAdmin', + 'boost': 600, + 'query': 'three' + } + } + }, + { + 'match': { + 'parent.localadmin': { + 'analyzer': 'peliasAdmin', + 'boost': 200, + 'query': 'three' + } + } + }, + { + 'match': { + 'parent.locality': { + 'analyzer': 'peliasAdmin', + 'boost': 200, + 'query': 'three' + } + } + }, + { + 'match': { + 'parent.neighbourhood': { + 'analyzer': 'peliasAdmin', + 'boost': 200, + 'query': 'three' + } + } + }, + { + 'match': { + 'phrase.default': { + 'analyzer' : 'peliasPhrase', + 'type' : 'phrase', + 'boost' : 1, + 'slop' : 3, + 'query' : 'one two' + } + } + }, + { + 'function_score': { + 'query': { 'match': { 'name.default': { 'analyzer': 'peliasQueryFullToken', - 'type': 'phrase', - 'boost': 1, - 'slop': 3, - 'query': 'one two' - } - } - } - ], - 'should': [ - { - 'match': { - 'parent.country': { - 'analyzer': 'peliasAdmin', - 'boost': 800, - 'query': 'three' - } - } - }, - { - 'match': { - 'parent.region': { - 'analyzer': 'peliasAdmin', - 'boost': 600, - 'query': 'three' + 'query': 'one two', } } }, - { - 'match': { - 'parent.region_a': { - 'analyzer': 'peliasAdmin', - 'boost': 600, - 'query': 'three' - } - } - }, - { - 'match': { - 'parent.county': { - 'analyzer': 'peliasAdmin', - 'boost': 400, - 'query': 'three' - } - } - }, - { - 'match': { - 'parent.borough': { - 'analyzer': 'peliasAdmin', - 'boost': 600, - 'query': 'three' - } - } - }, - { - 'match': { - 'parent.localadmin': { - 'analyzer': 'peliasAdmin', - 'boost': 200, - 'query': 'three' - } - } - }, - { - 'match': { - 'parent.locality': { - 'analyzer': 'peliasAdmin', - 'boost': 200, - 'query': 'three' - } - } - }, - { - 'match': { - 'parent.neighbourhood': { - 'analyzer': 'peliasAdmin', - 'boost': 200, - 'query': 'three' - } + 'max_boost': 20, + 'functions': [ + { + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 } - }, - { + ], + 'score_mode': 'first', + 'boost_mode': 'replace' + } + }, + { + 'function_score': { + 'query': { 'match': { - 'phrase.default': { - 'analyzer' : 'peliasPhrase', - 'type' : 'phrase', - 'boost' : 1, - 'slop' : 3, - 'query' : 'one two' + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'query': 'one two', } } }, - { - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one two', - } - } - }, - 'max_boost': 20, - 'functions': [ - { - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - } - ], - 'score_mode': 'first', - 'boost_mode': 'replace' - } - }, - { - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one two', - } - } + 'max_boost': 20, + 'functions': [ + { + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 }, - 'max_boost': 20, - 'functions': [ - { - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 3 - } - ], - 'score_mode': 'first', - 'boost_mode': 'replace' + 'weight': 3 } - } - ] + ], + 'score_mode': 'first', + 'boost_mode': 'replace' + } } - } + ] } }, 'size': 20, diff --git a/test/unit/fixture/autocomplete_single_character_street.js b/test/unit/fixture/autocomplete_single_character_street.js index f89e8493..056e4554 100644 --- a/test/unit/fixture/autocomplete_single_character_street.js +++ b/test/unit/fixture/autocomplete_single_character_street.js @@ -1,152 +1,148 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'type': 'phrase', + 'boost': 1, + 'slop': 3, + 'query': 'k road' + } + } + }], + 'should':[ + { + 'match': { + 'address_parts.street': { + 'query': 'k road', + 'boost': 5, + 'analyzer': 'peliasStreet' + } + } + }, { + 'match': { + 'parent.country': { + 'query': 'laird', + 'boost': 800, + 'analyzer': 'peliasAdmin' + } + } + }, { + 'match': { + 'parent.region': { + 'query': 'laird', + 'boost': 600, + 'analyzer': 'peliasAdmin' + } + } + }, { + 'match': { + 'parent.region_a': { + 'query': 'laird', + 'boost': 600, + 'analyzer': 'peliasAdmin' + } + } + }, { + 'match': { + 'parent.county': { + 'query': 'laird', + 'boost': 400, + 'analyzer': 'peliasAdmin' + } + } + }, { + 'match': { + 'parent.borough': { + 'analyzer': 'peliasAdmin', + 'boost': 600, + 'query': 'laird' + } + } + }, { + 'match': { + 'parent.localadmin': { + 'query': 'laird', + 'boost': 200, + 'analyzer': 'peliasAdmin' + } + } + }, { + 'match': { + 'parent.locality': { + 'query': 'laird', + 'boost': 200, + 'analyzer': 'peliasAdmin' + } + } + }, { + 'match': { + 'parent.neighbourhood': { + 'query': 'laird', + 'boost': 200, + 'analyzer': 'peliasAdmin' + } + } + }, + { + 'match': { + 'phrase.default': { + 'analyzer' : 'peliasPhrase', + 'type' : 'phrase', + 'boost' : 1, + 'slop' : 3, + 'query' : 'k road' + } + } + }, + { + 'function_score': { + 'query': { 'match': { 'name.default': { 'analyzer': 'peliasQueryFullToken', - 'type': 'phrase', - 'boost': 1, - 'slop': 3, - 'query': 'k road' + 'query': 'k road', } } - }], - 'should':[ - { - 'match': { - 'address_parts.street': { - 'query': 'k road', - 'boost': 5, - 'analyzer': 'peliasStreet' - } - } - }, { - 'match': { - 'parent.country': { - 'query': 'laird', - 'boost': 800, - 'analyzer': 'peliasAdmin' - } - } - }, { - 'match': { - 'parent.region': { - 'query': 'laird', - 'boost': 600, - 'analyzer': 'peliasAdmin' - } - } - }, { - 'match': { - 'parent.region_a': { - 'query': 'laird', - 'boost': 600, - 'analyzer': 'peliasAdmin' - } - } - }, { - 'match': { - 'parent.county': { - 'query': 'laird', - 'boost': 400, - 'analyzer': 'peliasAdmin' - } - } - }, { - 'match': { - 'parent.borough': { - 'analyzer': 'peliasAdmin', - 'boost': 600, - 'query': 'laird' - } - } - }, { - 'match': { - 'parent.localadmin': { - 'query': 'laird', - 'boost': 200, - 'analyzer': 'peliasAdmin' - } - } - }, { - 'match': { - 'parent.locality': { - 'query': 'laird', - 'boost': 200, - 'analyzer': 'peliasAdmin' - } - } - }, { - 'match': { - 'parent.neighbourhood': { - 'query': 'laird', - 'boost': 200, - 'analyzer': 'peliasAdmin' - } - } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 }, - { - 'match': { - 'phrase.default': { - 'analyzer' : 'peliasPhrase', - 'type' : 'phrase', - 'boost' : 1, - 'slop' : 3, - 'query' : 'k road' - } + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'query': 'k road', } - }, - { - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'k road', - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'k road', - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 3 - }] } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 3 }] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/autocomplete_with_source_filtering.js b/test/unit/fixture/autocomplete_with_source_filtering.js index 075eb6d4..f41299dd 100644 --- a/test/unit/fixture/autocomplete_with_source_filtering.js +++ b/test/unit/fixture/autocomplete_with_source_filtering.js @@ -1,76 +1,68 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryPartialToken', + 'boost': 100, + 'query': 'test', + 'type': 'phrase', + 'operator': 'and' + } + } + }], + 'should':[{ + 'function_score': { + 'query': { 'match': { 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, + 'analyzer': 'peliasQueryFullToken', 'query': 'test', - 'type': 'phrase', - 'operator': 'and' } } - }], - 'should':[{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 3 - }] - } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 }] } - }, - 'filter': { - 'bool': { - 'must': [{ - 'terms': { - 'source': ['test_source'] + },{ + 'function_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryFullToken', + 'query': 'test', + } } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 3 }] } - } + }], + 'filter': [{ + 'terms': { + 'source': ['test_source'] + } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/reverse_null_island.js b/test/unit/fixture/reverse_null_island.js index 9620b36a..df6972ca 100644 --- a/test/unit/fixture/reverse_null_island.js +++ b/test/unit/fixture/reverse_null_island.js @@ -2,29 +2,18 @@ var vs = require('../../../query/reverse_defaults'); module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [] + 'bool': { + 'filter': [{ + 'geo_distance': { + 'distance': '500km', + 'distance_type': 'plane', + 'optimize_bbox': 'indexed', + 'center_point': { + 'lat': 0, + 'lon': 0 + } } - }, - 'filter': { - 'bool': { - 'must': [ - { - 'geo_distance': { - 'distance': '500km', - 'distance_type': 'plane', - 'optimize_bbox': 'indexed', - 'center_point': { - 'lat': 0, - 'lon': 0 - } - } - } - ] - } - } + }] } }, 'sort': [ diff --git a/test/unit/fixture/reverse_standard.js b/test/unit/fixture/reverse_standard.js index adab3ef4..b70fe958 100644 --- a/test/unit/fixture/reverse_standard.js +++ b/test/unit/fixture/reverse_standard.js @@ -2,29 +2,18 @@ var vs = require('../../../query/reverse_defaults'); module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [] + 'bool': { + 'filter': [{ + 'geo_distance': { + 'distance': '500km', + 'distance_type': 'plane', + 'optimize_bbox': 'indexed', + 'center_point': { + 'lat': 29.49136, + 'lon': -82.50622 + } } - }, - 'filter': { - 'bool': { - 'must': [ - { - 'geo_distance': { - 'distance': '500km', - 'distance_type': 'plane', - 'optimize_bbox': 'indexed', - 'center_point': { - 'lat': 29.49136, - 'lon': -82.50622 - } - } - } - ] - } - } + }] } }, 'sort': [ diff --git a/test/unit/fixture/reverse_with_boundary_country.js b/test/unit/fixture/reverse_with_boundary_country.js index c63b4ccc..c21cb44b 100644 --- a/test/unit/fixture/reverse_with_boundary_country.js +++ b/test/unit/fixture/reverse_with_boundary_country.js @@ -2,38 +2,28 @@ var vs = require('../../../query/reverse_defaults'); module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [ - { - 'match': { - 'parent.country_a': { - 'analyzer': 'standard', - 'query': 'ABC' - } - } + 'bool': { + 'must': [ + { + 'match': { + 'parent.country_a': { + 'analyzer': 'standard', + 'query': 'ABC' } - ] + } } - }, - 'filter': { - 'bool': { - 'must': [ - { - 'geo_distance': { - 'distance': '500km', - 'distance_type': 'plane', - 'optimize_bbox': 'indexed', - 'center_point': { - 'lat': 29.49136, - 'lon': -82.50622 - } - } - } - ] + ], + 'filter': [{ + 'geo_distance': { + 'distance': '500km', + 'distance_type': 'plane', + 'optimize_bbox': 'indexed', + 'center_point': { + 'lat': 29.49136, + 'lon': -82.50622 + } } - } + }] } }, 'sort': [ diff --git a/test/unit/fixture/reverse_with_source_filtering.js b/test/unit/fixture/reverse_with_source_filtering.js index e81c98ef..21e04662 100644 --- a/test/unit/fixture/reverse_with_source_filtering.js +++ b/test/unit/fixture/reverse_with_source_filtering.js @@ -2,34 +2,25 @@ var vs = require('../../../query/reverse_defaults'); module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [] - } - }, - 'filter': { - 'bool': { - 'must': [ - { - 'geo_distance': { - 'distance': '500km', - 'distance_type': 'plane', - 'optimize_bbox': 'indexed', - 'center_point': { - 'lat': 29.49136, - 'lon': -82.50622 - } - } - }, - { - 'terms': { - 'source': ['test'] - } + 'bool': { + 'filter': [ + { + 'geo_distance': { + 'distance': '500km', + 'distance_type': 'plane', + 'optimize_bbox': 'indexed', + 'center_point': { + 'lat': 29.49136, + 'lon': -82.50622 } - ] + } + }, + { + 'terms': { + 'source': ['test'] + } } - } + ] } }, 'sort': [ diff --git a/test/unit/fixture/search_boundary_country.js b/test/unit/fixture/search_boundary_country.js index 71965df4..37d31c3b 100644 --- a/test/unit/fixture/search_boundary_country.js +++ b/test/unit/fixture/search_boundary_country.js @@ -1,91 +1,87 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [ - { - 'match': { - 'parent.country_a': { - 'analyzer': 'standard', - 'query': 'ABC' - } - } - }, - { - 'match': { - 'name.default': { - 'query': 'test', - 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' - } - } + 'bool': { + 'must': [ + { + 'match': { + 'parent.country_a': { + 'analyzer': 'standard', + 'query': 'ABC' } - ], - 'should': [{ + } + }, + { + 'match': { + 'name.default': { + 'query': 'test', + 'boost': 1, + 'analyzer': 'peliasIndexOneEdgeGram' + } + } + } + ], + 'should': [{ + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'boost': 1, + 'slop': 2 + } + } + },{ + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'query': 'test', 'analyzer': 'peliasPhrase', 'type': 'phrase', - 'boost': 1, - 'slop': 2 + 'slop': 2, + 'boost': 1 } } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - }] + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 }] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/search_full_address.js b/test/unit/fixture/search_full_address.js index ea85f716..5ebb0004 100644 --- a/test/unit/fixture/search_full_address.js +++ b/test/unit/fixture/search_full_address.js @@ -2,19 +2,55 @@ var vs = require('../../../query/search_defaults'); module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'query': '123 main st', + 'analyzer': 'peliasIndexOneEdgeGram', + 'boost': 1 + } + } + }], + 'should': [{ + 'match': { + 'phrase.default': { + 'query': '123 main st', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + { + 'function_score': { + 'query': { 'match': { - 'name.default': { + 'phrase.default': { 'query': '123 main st', - 'analyzer': 'peliasIndexOneEdgeGram', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, 'boost': 1 } } - }], - 'should': [{ + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'query': '123 main st', @@ -25,114 +61,74 @@ module.exports = { } } }, - { - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': '123 main st', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': '123 main st', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - }] - } - },{ - 'match': { - 'address_parts.number': { - 'query': '123', - 'boost': vs['address:housenumber:boost'], - 'analyzer': vs['address:housenumber:analyzer'] - } - } - }, { - 'match': { - 'address_parts.street': { - 'query': 'main st', - 'boost': vs['address:street:boost'], - 'analyzer': vs['address:street:analyzer'] - } - } - }, { - 'match': { - 'address_parts.zip': { - 'query': '10010', - 'boost': vs['address:postcode:boost'], - 'analyzer': vs['address:postcode:analyzer'] - } - } - }, { - 'match': { - 'parent.country_a': { - 'query': 'USA', - 'boost': vs['admin:country_a:boost'], - 'analyzer': vs['admin:country_a:analyzer'] - } - } - }, { - 'match': { - 'parent.region_a': { - 'query': 'NY', - 'boost': vs['admin:region_a:boost'], - 'analyzer': vs['admin:region_a:analyzer'] - } - } - }, { - 'multi_match': { - 'fields': [ - 'parent.country^1', - 'parent.region^1', - 'parent.county^1', - 'parent.localadmin^1', - 'parent.locality^1', - 'parent.borough^1', - 'parent.neighbourhood^1', - 'parent.region_a^1' - ], - 'query': 'new york', - 'analyzer': 'peliasAdmin' - } + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 }] } - } + },{ + 'match': { + 'address_parts.number': { + 'query': '123', + 'boost': vs['address:housenumber:boost'], + 'analyzer': vs['address:housenumber:analyzer'] + } + } + }, { + 'match': { + 'address_parts.street': { + 'query': 'main st', + 'boost': vs['address:street:boost'], + 'analyzer': vs['address:street:analyzer'] + } + } + }, { + 'match': { + 'address_parts.zip': { + 'query': '10010', + 'boost': vs['address:postcode:boost'], + 'analyzer': vs['address:postcode:analyzer'] + } + } + }, { + 'match': { + 'parent.country_a': { + 'query': 'USA', + 'boost': vs['admin:country_a:boost'], + 'analyzer': vs['admin:country_a:analyzer'] + } + } + }, { + 'match': { + 'parent.region_a': { + 'query': 'NY', + 'boost': vs['admin:region_a:boost'], + 'analyzer': vs['admin:region_a:analyzer'] + } + } + }, { + 'multi_match': { + 'fields': [ + 'parent.country^1', + 'parent.region^1', + 'parent.county^1', + 'parent.localadmin^1', + 'parent.locality^1', + 'parent.borough^1', + 'parent.neighbourhood^1', + 'parent.region_a^1' + ], + 'query': 'new york', + 'analyzer': 'peliasAdmin' + } + }] } }, 'size': 10, diff --git a/test/unit/fixture/search_linguistic_bbox.js b/test/unit/fixture/search_linguistic_bbox.js index a672eb15..8a9b7849 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -1,96 +1,88 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'query': 'test', + 'boost': 1, + 'analyzer': 'peliasIndexOneEdgeGram' + } + } + }], + 'should': [{ + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'boost': 1, + 'slop': 2 + } + } + },{ + 'function_score': { + 'query': { 'match': { - 'name.default': { + 'phrase.default': { 'query': 'test', - 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } - }], - 'should': [{ + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'query': 'test', 'analyzer': 'peliasPhrase', 'type': 'phrase', - 'boost': 1, - 'slop': 2 + 'slop': 2, + 'boost': 1 } } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - }] - } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 }] } - }, - 'filter': { - 'bool': { - 'must': [{ - 'geo_bounding_box': { - 'center_point': { - 'top': 11.51, - 'right': -61.84, - 'bottom': 47.47, - 'left': -103.16 - }, - 'type': 'indexed' - } - }] + }], + 'filter': [{ + 'geo_bounding_box': { + 'center_point': { + 'top': 11.51, + 'right': -61.84, + 'bottom': 47.47, + 'left': -103.16 + }, + 'type': 'indexed' } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/search_linguistic_focus.js b/test/unit/fixture/search_linguistic_focus.js index da3e8fb3..0fdf03f0 100644 --- a/test/unit/fixture/search_linguistic_focus.js +++ b/test/unit/fixture/search_linguistic_focus.js @@ -1,111 +1,107 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'query': 'test', + 'boost': 1, + 'analyzer': 'peliasIndexOneEdgeGram' + } + } + }], + 'should': [{ + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'boost': 1, + 'slop': 2 + } + } + }, { + 'function_score': { + 'query': { 'match': { - 'name.default': { - 'query': 'test', + 'phrase.default': { + 'analyzer': 'peliasPhrase', + 'type': 'phrase', 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'slop': 2, + 'query': 'test' } } + }, + 'functions': [{ + 'linear': { + 'center_point': { + 'origin': { + 'lat': 29.49136, + 'lon': -82.50622 + }, + 'offset': '1km', + 'scale': '50km', + 'decay': 0.5 + } + }, + 'weight': 2 }], - 'should': [{ + 'score_mode': 'avg', + 'boost_mode': 'replace' + } + },{ + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'query': 'test', 'analyzer': 'peliasPhrase', 'type': 'phrase', - 'boost': 1, - 'slop': 2 + 'slop': 2, + 'boost': 1 } } - }, { - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'boost': 1, - 'slop': 2, - 'query': 'test' - } - } - }, - 'functions': [{ - 'linear': { - 'center_point': { - 'origin': { - 'lat': 29.49136, - 'lon': -82.50622 - }, - 'offset': '1km', - 'scale': '50km', - 'decay': 0.5 - } - }, - 'weight': 2 - }], - 'score_mode': 'avg', - 'boost_mode': 'replace' - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - }] + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 }] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/search_linguistic_focus_bbox.js b/test/unit/fixture/search_linguistic_focus_bbox.js index b9785532..d27791cb 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -1,126 +1,118 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'query': 'test', + 'boost': 1, + 'analyzer': 'peliasIndexOneEdgeGram' + } + } + }], + 'should': [{ + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'boost': 1, + 'slop': 2 + } + } + }, { + 'function_score': { + 'query': { 'match': { - 'name.default': { - 'query': 'test', + 'phrase.default': { + 'analyzer': 'peliasPhrase', + 'type': 'phrase', 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'slop': 2, + 'query': 'test' } } + }, + 'functions': [{ + 'linear': { + 'center_point': { + 'origin': { + 'lat': 29.49136, + 'lon': -82.50622 + }, + 'offset': '1km', + 'scale': '50km', + 'decay': 0.5 + } + }, + 'weight': 2 }], - 'should': [{ + 'score_mode': 'avg', + 'boost_mode': 'replace' + } + },{ + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'query': 'test', 'analyzer': 'peliasPhrase', 'type': 'phrase', - 'boost': 1, - 'slop': 2 + 'slop': 2, + 'boost': 1 } } - }, { - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'boost': 1, - 'slop': 2, - 'query': 'test' - } - } - }, - 'functions': [{ - 'linear': { - 'center_point': { - 'origin': { - 'lat': 29.49136, - 'lon': -82.50622 - }, - 'offset': '1km', - 'scale': '50km', - 'decay': 0.5 - } - }, - 'weight': 2 - }], - 'score_mode': 'avg', - 'boost_mode': 'replace' - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - }] - } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 }] } - }, - 'filter': { - 'bool': { - 'must': [{ - 'geo_bounding_box': { - 'center_point': { - 'top': 11.51, - 'right': -61.84, - 'bottom': 47.47, - 'left': -103.16 - }, - 'type': 'indexed' + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 }] } - } + }], + 'filter': [{ + 'geo_bounding_box': { + 'center_point': { + 'top': 11.51, + 'right': -61.84, + 'bottom': 47.47, + 'left': -103.16 + }, + 'type': 'indexed' + } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/search_linguistic_focus_null_island.js b/test/unit/fixture/search_linguistic_focus_null_island.js index b99febea..e191400a 100644 --- a/test/unit/fixture/search_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_linguistic_focus_null_island.js @@ -1,111 +1,107 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'query': 'test', + 'boost': 1, + 'analyzer': 'peliasIndexOneEdgeGram' + } + } + }], + 'should': [{ + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'boost': 1, + 'slop': 2 + } + } + }, { + 'function_score': { + 'query': { 'match': { - 'name.default': { - 'query': 'test', + 'phrase.default': { + 'analyzer': 'peliasPhrase', + 'type': 'phrase', 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'slop': 2, + 'query': 'test' } } + }, + 'functions': [{ + 'linear': { + 'center_point': { + 'origin': { + 'lat': 0, + 'lon': 0 + }, + 'offset': '1km', + 'scale': '50km', + 'decay': 0.5 + } + }, + 'weight': 2 }], - 'should': [{ + 'score_mode': 'avg', + 'boost_mode': 'replace' + } + },{ + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'query': 'test', 'analyzer': 'peliasPhrase', 'type': 'phrase', - 'boost': 1, - 'slop': 2 + 'slop': 2, + 'boost': 1 } } - }, { - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'boost': 1, - 'slop': 2, - 'query': 'test' - } - } - }, - 'functions': [{ - 'linear': { - 'center_point': { - 'origin': { - 'lat': 0, - 'lon': 0 - }, - 'offset': '1km', - 'scale': '50km', - 'decay': 0.5 - } - }, - 'weight': 2 - }], - 'score_mode': 'avg', - 'boost_mode': 'replace' - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - }] + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 }] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/search_linguistic_only.js b/test/unit/fixture/search_linguistic_only.js index a564a4c1..d0e02c16 100644 --- a/test/unit/fixture/search_linguistic_only.js +++ b/test/unit/fixture/search_linguistic_only.js @@ -1,81 +1,77 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'query': 'test', + 'boost': 1, + 'analyzer': 'peliasIndexOneEdgeGram' + } + } + }], + 'should': [{ + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'boost': 1, + 'slop': 2 + } + } + },{ + 'function_score': { + 'query': { 'match': { - 'name.default': { + 'phrase.default': { 'query': 'test', - 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } - }], - 'should': [{ + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'query': 'test', 'analyzer': 'peliasPhrase', 'type': 'phrase', - 'boost': 1, - 'slop': 2 + 'slop': 2, + 'boost': 1 } } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - }] - } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 }] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/fixture/search_linguistic_viewport.js b/test/unit/fixture/search_linguistic_viewport.js index b85d8322..b0339134 100644 --- a/test/unit/fixture/search_linguistic_viewport.js +++ b/test/unit/fixture/search_linguistic_viewport.js @@ -1,21 +1,65 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [ - { + 'bool': { + 'must': [ + { + 'match': { + 'name.default': { + 'analyzer': 'peliasIndexOneEdgeGram', + 'boost': 1, + 'query': 'test' + } + } + } + ], + 'should': [ + { + 'match': { + 'phrase.default': { + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'boost': 1, + 'slop': 2, + 'query': 'test' + } + } + }, + { + 'function_score': { + 'query': { 'match': { - 'name.default': { - 'analyzer': 'peliasIndexOneEdgeGram', + 'phrase.default': { + 'analyzer': 'peliasPhrase', + 'type': 'phrase', 'boost': 1, + 'slop': 2, 'query': 'test' } } - } - ], - 'should': [ - { + }, + 'functions': [ + { + 'weight': 2, + 'linear': { + 'center_point': { + 'origin': { + 'lat': 29.49136, + 'lon': -82.50622 + }, + 'offset': '1km', + 'scale': '50km', + 'decay': 0.5 + } + } + } + ], + 'score_mode': 'avg', + 'boost_mode': 'replace' + } + }, + { + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'analyzer': 'peliasPhrase', @@ -26,98 +70,50 @@ module.exports = { } } }, - { - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'boost': 1, - 'slop': 2, - 'query': 'test' - } - } + 'max_boost': 20, + 'functions': [ + { + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 }, - 'functions': [ - { - 'weight': 2, - 'linear': { - 'center_point': { - 'origin': { - 'lat': 29.49136, - 'lon': -82.50622 - }, - 'offset': '1km', - 'scale': '50km', - 'decay': 0.5 - } - } - } - ], - 'score_mode': 'avg', - 'boost_mode': 'replace' + 'weight': 1 } - }, - { - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'boost': 1, - 'slop': 2, - 'query': 'test' - } - } - }, - 'max_boost': 20, - 'functions': [ - { - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - } - ], - 'score_mode': 'first', - 'boost_mode': 'replace' + ], + 'score_mode': 'first', + 'boost_mode': 'replace' + } + }, + { + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'boost': 1, + 'slop': 2, + 'query': 'test' + } } }, - { - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'boost': 1, - 'slop': 2, - 'query': 'test' - } - } + 'max_boost': 20, + 'functions': [ + { + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 }, - 'max_boost': 20, - 'functions': [ - { - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - } - ], - 'score_mode': 'first', - 'boost_mode': 'replace' + 'weight': 2 } - } - ] + ], + 'score_mode': 'first', + 'boost_mode': 'replace' + } } - } + ] } }, 'size': 10, diff --git a/test/unit/fixture/search_partial_address.js b/test/unit/fixture/search_partial_address.js index a6cf47e5..47acb4ac 100644 --- a/test/unit/fixture/search_partial_address.js +++ b/test/unit/fixture/search_partial_address.js @@ -3,19 +3,54 @@ var vs = require('../../../query/search_defaults'); module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'query': 'soho grand', + 'analyzer': 'peliasIndexOneEdgeGram', + 'boost': 1 + } + } + }], + 'should': [{ + 'match': { + 'phrase.default': { + 'query': 'soho grand', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + },{ + 'function_score': { + 'query': { 'match': { - 'name.default': { + 'phrase.default': { 'query': 'soho grand', - 'analyzer': 'peliasIndexOneEdgeGram', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, 'boost': 1 } } - }], - 'should': [{ + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'query': 'soho grand', @@ -25,82 +60,43 @@ module.exports = { 'boost': 1 } } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'soho grand', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'soho grand', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - }] - } - }, { - 'match': { - 'parent.region_a': { - 'analyzer': 'peliasAdmin', - 'boost': 1, - 'query': 'new york' - } - } - }, { - 'multi_match': { - 'fields': [ - 'parent.country^1', - 'parent.region^1', - 'parent.county^1', - 'parent.localadmin^1', - 'parent.locality^1', - 'parent.borough^1', - 'parent.neighbourhood^1', - 'parent.region_a^1' - ], - 'query': 'new york', - 'analyzer': 'peliasAdmin' - } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 }] } - } + }, { + 'match': { + 'parent.region_a': { + 'analyzer': 'peliasAdmin', + 'boost': 1, + 'query': 'new york' + } + } + }, { + 'multi_match': { + 'fields': [ + 'parent.country^1', + 'parent.region^1', + 'parent.county^1', + 'parent.localadmin^1', + 'parent.locality^1', + 'parent.borough^1', + 'parent.neighbourhood^1', + 'parent.region_a^1' + ], + 'query': 'new york', + 'analyzer': 'peliasAdmin' + } + }] } }, 'size': 10, diff --git a/test/unit/fixture/search_regions_address.js b/test/unit/fixture/search_regions_address.js index 195358c7..a133da38 100644 --- a/test/unit/fixture/search_regions_address.js +++ b/test/unit/fixture/search_regions_address.js @@ -3,19 +3,54 @@ var vs = require('../../../query/search_defaults'); module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'query': '1 water st', + 'analyzer': 'peliasIndexOneEdgeGram', + 'boost': 1 + } + } + }], + 'should': [{ + 'match': { + 'phrase.default': { + 'query': '1 water st', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + },{ + 'function_score': { + 'query': { 'match': { - 'name.default': { + 'phrase.default': { 'query': '1 water st', - 'analyzer': 'peliasIndexOneEdgeGram', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, 'boost': 1 } } - }], - 'should': [{ + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'query': '1 water st', @@ -25,98 +60,59 @@ module.exports = { 'boost': 1 } } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': '1 water st', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': '1 water st', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - }] - } - },{ - 'match': { - 'address_parts.number': { - 'query': '1', - 'boost': vs['address:housenumber:boost'], - 'analyzer': vs['address:housenumber:analyzer'] - } - } - }, { - 'match': { - 'address_parts.street': { - 'query': 'water st', - 'boost': vs['address:street:boost'], - 'analyzer': vs['address:street:analyzer'] - } - } - }, { - 'match': { - 'parent.region_a': { - 'query': 'NY', - 'boost': vs['admin:region_a:boost'], - 'analyzer': vs['admin:region_a:analyzer'] - } - } - }, { - 'multi_match': { - 'fields': [ - 'parent.country^1', - 'parent.region^1', - 'parent.county^1', - 'parent.localadmin^1', - 'parent.locality^1', - 'parent.borough^1', - 'parent.neighbourhood^1', - 'parent.region_a^1' - ], - 'query': 'manhattan', - 'analyzer': 'peliasAdmin' - } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 }] } - } + },{ + 'match': { + 'address_parts.number': { + 'query': '1', + 'boost': vs['address:housenumber:boost'], + 'analyzer': vs['address:housenumber:analyzer'] + } + } + }, { + 'match': { + 'address_parts.street': { + 'query': 'water st', + 'boost': vs['address:street:boost'], + 'analyzer': vs['address:street:analyzer'] + } + } + }, { + 'match': { + 'parent.region_a': { + 'query': 'NY', + 'boost': vs['admin:region_a:boost'], + 'analyzer': vs['admin:region_a:analyzer'] + } + } + }, { + 'multi_match': { + 'fields': [ + 'parent.country^1', + 'parent.region^1', + 'parent.county^1', + 'parent.localadmin^1', + 'parent.locality^1', + 'parent.borough^1', + 'parent.neighbourhood^1', + 'parent.region_a^1' + ], + 'query': 'manhattan', + 'analyzer': 'peliasAdmin' + } + }] } }, 'size': 10, diff --git a/test/unit/fixture/search_with_source_filtering.js b/test/unit/fixture/search_with_source_filtering.js index 18ee13a3..8feb6820 100644 --- a/test/unit/fixture/search_with_source_filtering.js +++ b/test/unit/fixture/search_with_source_filtering.js @@ -1,90 +1,82 @@ module.exports = { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'must': [{ + 'bool': { + 'must': [{ + 'match': { + 'name.default': { + 'query': 'test', + 'boost': 1, + 'analyzer': 'peliasIndexOneEdgeGram' + } + } + }], + 'should': [{ + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'boost': 1, + 'slop': 2 + } + } + },{ + 'function_score': { + 'query': { 'match': { - 'name.default': { + 'phrase.default': { 'query': 'test', - 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } - }], - 'should': [{ + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'popularity', + 'missing': 1 + }, + 'weight': 1 + }] + } + },{ + 'function_score': { + 'query': { 'match': { 'phrase.default': { 'query': 'test', 'analyzer': 'peliasPhrase', 'type': 'phrase', - 'boost': 1, - 'slop': 2 + 'slop': 2, + 'boost': 1 } } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'popularity', - 'missing': 1 - }, - 'weight': 1 - }] - } - },{ - 'function_score': { - 'query': { - 'match': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'type': 'phrase', - 'slop': 2, - 'boost': 1 - } - } - }, - 'max_boost': 20, - 'score_mode': 'first', - 'boost_mode': 'replace', - 'functions': [{ - 'field_value_factor': { - 'modifier': 'log1p', - 'field': 'population', - 'missing': 1 - }, - 'weight': 2 - }] - } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population', + 'missing': 1 + }, + 'weight': 2 }] } - }, - 'filter': { - 'bool': { - 'must': [{ - 'terms': { - 'source': ['test_source'] - } - }] + }], + 'filter': [{ + 'terms': { + 'source': ['test_source'] } - } + }] } }, 'sort': [ '_score' ], diff --git a/test/unit/query/reverse.js b/test/unit/query/reverse.js index 4060d679..db0daa12 100644 --- a/test/unit/query/reverse.js +++ b/test/unit/query/reverse.js @@ -22,7 +22,7 @@ module.exports.tests.query = function(test, common) { var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/reverse_standard'); - t.deepEqual(compiled, expected, 'valid reverse query'); + t.deepEqual(compiled, expected, 'reverse_standard'); t.end(); }); @@ -38,7 +38,7 @@ module.exports.tests.query = function(test, common) { var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/reverse_null_island'); - t.deepEqual(compiled, expected, 'valid reverse query'); + t.deepEqual(compiled, expected, 'reverse_null_island'); t.end(); }); @@ -54,7 +54,7 @@ module.exports.tests.query = function(test, common) { var compiled = JSON.parse( JSON.stringify( query ) ); var expected = '123km'; - t.deepEqual(compiled.query.filtered.filter.bool.must[0].geo_distance.distance, expected, 'distance set to boundary circle radius'); + t.deepEqual(compiled.query.bool.filter[0].geo_distance.distance, expected, 'distance set to boundary circle radius'); t.end(); }); @@ -71,9 +71,9 @@ module.exports.tests.query = function(test, common) { // this should not equal `point.lat` and `point.lon` as it was explitely specified var expected = { lat: clean['boundary.circle.lat'], lon: clean['boundary.circle.lon'] }; - var centroid = compiled.query.filtered.filter.bool.must[0].geo_distance.center_point; + var centroid = compiled.query.bool.filter[0].geo_distance.center_point; - t.deepEqual(centroid, expected, 'boundary.circle/lon overrides point.lat/lon'); + t.deepEqual(centroid, expected, 'reverse: boundary.circle/lon overrides point.lat/lon'); t.end(); }); diff --git a/test/unit/query/search.js b/test/unit/query/search.js index a2bb8e2f..29c8a06e 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -178,7 +178,7 @@ module.exports.tests.query = function(test, common) { var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/search_boundary_country'); - t.deepEqual(compiled, expected, 'valid boundary.country query'); + t.deepEqual(compiled, expected, 'search: valid boundary.country query'); t.end(); }); @@ -191,7 +191,7 @@ module.exports.tests.query = function(test, common) { var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/search_with_source_filtering'); - t.deepEqual(compiled, expected, 'valid search query with source filtering'); + t.deepEqual(compiled, expected, 'search: valid search query with source filtering'); t.end(); }); From e22b973cdf7aa1125dd22905fa367750731c8502 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Mon, 13 Jun 2016 11:24:58 +0300 Subject: [PATCH 03/14] Do not consider absence of an additional name as a difference OSM data includes two almost identical 'Keskustori, Tampere' entries. The second one does not have additional 'name.ru' property. This is no longer considered as a difference in deduping. --- middleware/dedupe.js | 5 +++- .../fixture/dedupe_elasticsearch_results.js | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/middleware/dedupe.js b/middleware/dedupe.js index 7adb33e2..3723512b 100644 --- a/middleware/dedupe.js +++ b/middleware/dedupe.js @@ -51,7 +51,10 @@ function isDifferent(item1, item2) { if (item1.hasOwnProperty('name') && item2.hasOwnProperty('name')) { for (var lang in item1.name) { - propMatch(item1.name, item2.name, lang); + if(item2.name[lang] || lang === 'default') { + // do not consider absence of an additional name as a difference + propMatch(item1.name, item2.name, lang); + } } } else { diff --git a/test/unit/fixture/dedupe_elasticsearch_results.js b/test/unit/fixture/dedupe_elasticsearch_results.js index 59da3746..e4780097 100644 --- a/test/unit/fixture/dedupe_elasticsearch_results.js +++ b/test/unit/fixture/dedupe_elasticsearch_results.js @@ -80,6 +80,34 @@ module.exports = [ '_score': 1.2367082, 'confidence': 0.879 }, + { // same as #1, but with an additional name + 'center_point': { + 'lon': -76.207456, + 'lat': 40.039265 + }, + 'address_parts': {}, + 'parent': { + 'localadmin': ['East Lampeter'], + 'region_a': ['PA'], + 'region': ['Pennsylvania'], + 'locality': ['Smoketown'], + 'country_a': ['USA'], + 'county': ['Lancaster County'], + 'country': ['United States'], + 'neighbourhood': ['Greenland'] + }, + 'name': { + 'default': 'East Lampeter High School', + 'alt': 'High School of East Lampeter', + }, + 'category': [ + 'education' + ], + '_id': '357321757', + '_type': 'venue', + '_score': 1.2367082, + 'confidence': 0.879 + }, { 'center_point': { 'lon': -76.207456, From a4c31b6f8d3ba2eba86a4154b10814e18a45b36b Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Mon, 13 Jun 2016 17:40:29 -0400 Subject: [PATCH 04/14] fix: Explicitly depend on packages' optional dependencies [istanbul](https://www.npmjs.com/package/istanbul) and [escodegen](https://www.npmjs.com/package/escodegen) have optional dependencies, which for some reason `npm ls` in npm version 3 fails to handle properly. We don't need these packages, but installing them does little harm so it seems to be the best way to make our precommit-hook scripts pass for all users. --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 53c7fab0..4d8d3c6c 100644 --- a/package.json +++ b/package.json @@ -66,8 +66,10 @@ "nsp": "^2.2.0", "precommit-hook": "^3.0.0", "proxyquire": "^1.7.7", + "source-map": "^0.5.6", "tap-dot": "1.0.5", - "tape": "^4.5.1" + "tape": "^4.5.1", + "uglify-js": "^2.6.2" }, "pre-commit": [ "lint", From 73f64ce3e1f6d48762ddba20dcbdef974ae8f7bc Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Thu, 16 Jun 2016 08:36:49 +0300 Subject: [PATCH 05/14] Cleanup: tabs -> spaces --- middleware/dedupe.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/middleware/dedupe.js b/middleware/dedupe.js index 3723512b..786675c4 100644 --- a/middleware/dedupe.js +++ b/middleware/dedupe.js @@ -51,10 +51,10 @@ function isDifferent(item1, item2) { if (item1.hasOwnProperty('name') && item2.hasOwnProperty('name')) { for (var lang in item1.name) { - if(item2.name[lang] || lang === 'default') { - // do not consider absence of an additional name as a difference - propMatch(item1.name, item2.name, lang); - } + if(item2.name[lang] || lang === 'default') { + // do not consider absence of an additional name as a difference + propMatch(item1.name, item2.name, lang); + } } } else { From 801f86c5cc9695f50d137b570b57c97d4b02272e Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Tue, 21 Jun 2016 13:57:10 -0700 Subject: [PATCH 06/14] chore(package): update pelias-query to version 7.0.2 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d8d3c6c..073a8b6b 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "pelias-config": "^1.0.1", "pelias-logger": "^0.0.8", "pelias-model": "^4.0.0", - "pelias-query": "7.0.1", + "pelias-query": "7.0.2", "pelias-suggester-pipeline": "2.0.4", "pelias-text-analyzer": "^1.0.1", "stats-lite": "1.0.3", From cb35f373127bb3680f9c97b8fe8a276ee5503552 Mon Sep 17 00:00:00 2001 From: missinglink Date: Wed, 22 Jun 2016 19:01:30 +0200 Subject: [PATCH 07/14] focus minimum set to 0km instead of 1km --- query/reverse_defaults.js | 2 +- query/search_defaults.js | 2 +- test/unit/fixture/search_linguistic_focus.js | 2 +- test/unit/fixture/search_linguistic_focus_bbox.js | 2 +- test/unit/fixture/search_linguistic_focus_null_island.js | 2 +- test/unit/fixture/search_linguistic_viewport.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/query/reverse_defaults.js b/query/reverse_defaults.js index 8392183f..d21caa9b 100644 --- a/query/reverse_defaults.js +++ b/query/reverse_defaults.js @@ -31,7 +31,7 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'phrase:slop': 2, 'focus:function': 'linear', - 'focus:offset': '1km', + 'focus:offset': '0km', 'focus:scale': '50km', 'focus:decay': 0.5, 'focus:weight': 2, diff --git a/query/search_defaults.js b/query/search_defaults.js index 0ffdd79f..e2b18633 100644 --- a/query/search_defaults.js +++ b/query/search_defaults.js @@ -30,7 +30,7 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'phrase:slop': 2, 'focus:function': 'linear', - 'focus:offset': '1km', + 'focus:offset': '0km', 'focus:scale': '50km', 'focus:decay': 0.5, 'focus:weight': 2, diff --git a/test/unit/fixture/search_linguistic_focus.js b/test/unit/fixture/search_linguistic_focus.js index da3e8fb3..8d3684b8 100644 --- a/test/unit/fixture/search_linguistic_focus.js +++ b/test/unit/fixture/search_linguistic_focus.js @@ -43,7 +43,7 @@ module.exports = { 'lat': 29.49136, 'lon': -82.50622 }, - 'offset': '1km', + 'offset': '0km', 'scale': '50km', 'decay': 0.5 } diff --git a/test/unit/fixture/search_linguistic_focus_bbox.js b/test/unit/fixture/search_linguistic_focus_bbox.js index d5042c0f..0531fc9a 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -43,7 +43,7 @@ module.exports = { 'lat': 29.49136, 'lon': -82.50622 }, - 'offset': '1km', + 'offset': '0km', 'scale': '50km', 'decay': 0.5 } diff --git a/test/unit/fixture/search_linguistic_focus_null_island.js b/test/unit/fixture/search_linguistic_focus_null_island.js index b99febea..10c2d91c 100644 --- a/test/unit/fixture/search_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_linguistic_focus_null_island.js @@ -43,7 +43,7 @@ module.exports = { 'lat': 0, 'lon': 0 }, - 'offset': '1km', + 'offset': '0km', 'scale': '50km', 'decay': 0.5 } diff --git a/test/unit/fixture/search_linguistic_viewport.js b/test/unit/fixture/search_linguistic_viewport.js index b85d8322..5e1b2ba3 100644 --- a/test/unit/fixture/search_linguistic_viewport.js +++ b/test/unit/fixture/search_linguistic_viewport.js @@ -48,7 +48,7 @@ module.exports = { 'lat': 29.49136, 'lon': -82.50622 }, - 'offset': '1km', + 'offset': '0km', 'scale': '50km', 'decay': 0.5 } From 4b98b5e5199e494860fce2bfefb77106b5ae3857 Mon Sep 17 00:00:00 2001 From: missinglink Date: Wed, 22 Jun 2016 19:03:47 +0200 Subject: [PATCH 08/14] focus minimum set to 0km instead of 1km --- test/unit/fixture/search_linguistic_viewport_min_diagonal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js index e6b50ac6..67962109 100644 --- a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js +++ b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js @@ -48,7 +48,7 @@ module.exports = { 'lat': 28.49136, 'lon': -87.50623 }, - 'offset': '1km', + 'offset': '0km', 'scale': '1km', 'decay': 0.5 } From 52c35cb37db2aa4292f2502d8953c95a91a6ad1c Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 30 Jun 2016 13:16:31 +0200 Subject: [PATCH 09/14] allow single non-numeric chars, change boost_mode to 'replace' for function_score queries --- query/autocomplete_defaults.js | 2 +- query/view/ngrams_strict.js | 6 +++++ query/view/pop_subquery.js | 13 +++++------ sanitiser/_tokenizer.js | 8 +------ .../autocomplete_linguistic_final_token.js | 14 ++---------- .../fixture/autocomplete_linguistic_focus.js | 22 ++++++------------- ...tocomplete_linguistic_focus_null_island.js | 22 ++++++------------- ...autocomplete_linguistic_multiple_tokens.js | 17 ++++---------- .../fixture/autocomplete_linguistic_only.js | 17 ++++---------- .../autocomplete_linguistic_with_admin.js | 14 ++---------- .../autocomplete_single_character_street.js | 14 ++---------- .../autocomplete_with_source_filtering.js | 17 ++++---------- test/unit/sanitiser/_tokenizer.js | 6 +++-- 13 files changed, 50 insertions(+), 122 deletions(-) diff --git a/query/autocomplete_defaults.js b/query/autocomplete_defaults.js index 7233a436..2800141b 100644 --- a/query/autocomplete_defaults.js +++ b/query/autocomplete_defaults.js @@ -34,7 +34,7 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'focus:weight': 40, 'function_score:score_mode': 'avg', - 'function_score:boost_mode': 'multiply', + 'function_score:boost_mode': 'replace', 'address:housenumber:analyzer': 'peliasHousenumber', 'address:housenumber:field': 'address_parts.number', diff --git a/query/view/ngrams_strict.js b/query/view/ngrams_strict.js index 1f90ebe6..b0d7ae94 100644 --- a/query/view/ngrams_strict.js +++ b/query/view/ngrams_strict.js @@ -10,10 +10,16 @@ var peliasQuery = require('pelias-query'); module.exports = function( vs ){ + // validate required params + if( !vs.isset('phrase:slop') ){ + return null; + } + var view = peliasQuery.view.ngrams( vs ); view.match['name.default'].type = 'phrase'; view.match['name.default'].operator = 'and'; + view.match['name.default'].slop = vs.var('phrase:slop'); return view; }; diff --git a/query/view/pop_subquery.js b/query/view/pop_subquery.js index 724b773f..fc8f6804 100644 --- a/query/view/pop_subquery.js +++ b/query/view/pop_subquery.js @@ -4,14 +4,13 @@ var peliasQuery = require('pelias-query'), /** Population / Popularity subquery -**/ - -module.exports = function( vs ){ - var view = peliasQuery.view.ngrams( vs ); + In prior versions we have had restricted the population/popularity boost + to only a section of the query results. - view.match['name.default'].analyzer = vs.var('phrase:analyzer'); - delete view.match['name.default'].boost; + Currently it is configured to `match_all`, ie. targets all records. +**/ - return view; +module.exports = function( vs ){ + return { 'match_all': {} }; }; diff --git a/sanitiser/_tokenizer.js b/sanitiser/_tokenizer.js index 3312ea05..328cd1aa 100644 --- a/sanitiser/_tokenizer.js +++ b/sanitiser/_tokenizer.js @@ -92,13 +92,7 @@ function sanitize( raw, clean ){ // set all but the last token as 'complete' clean.tokens_complete = tokensCopy; - /** - if the last token is a single non-numeric character then we must discard it. - - at time of writing, single non-numeric ngrams are not stored in the index, - sending them as part of the query would result in 0 documents being returned. - **/ - if( lastToken && ( lastToken.length > 1 || lastToken.match(/[0-9]/) ) ){ + if( lastToken ){ clean.tokens_incomplete = [ lastToken ]; } } diff --git a/test/unit/fixture/autocomplete_linguistic_final_token.js b/test/unit/fixture/autocomplete_linguistic_final_token.js index b5f72a37..c27e64f5 100644 --- a/test/unit/fixture/autocomplete_linguistic_final_token.js +++ b/test/unit/fixture/autocomplete_linguistic_final_token.js @@ -26,12 +26,7 @@ module.exports = { },{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', @@ -48,12 +43,7 @@ module.exports = { },{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', diff --git a/test/unit/fixture/autocomplete_linguistic_focus.js b/test/unit/fixture/autocomplete_linguistic_focus.js index 7543eabd..a9aea79d 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus.js +++ b/test/unit/fixture/autocomplete_linguistic_focus.js @@ -9,7 +9,8 @@ module.exports = { 'boost': 100, 'query': 'test', 'type': 'phrase', - 'operator': 'and' + 'operator': 'and', + 'slop': 3 } } }], @@ -22,7 +23,8 @@ module.exports = { 'boost': 100, 'query': 'test', 'type': 'phrase', - 'operator': 'and' + 'operator': 'and', + 'slop': 3 } } }, @@ -41,7 +43,7 @@ module.exports = { 'weight': 40 }], 'score_mode': 'avg', - 'boost_mode': 'multiply', + 'boost_mode': 'replace', 'filter': { 'or': [ { @@ -60,12 +62,7 @@ module.exports = { },{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', @@ -82,12 +79,7 @@ module.exports = { },{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', diff --git a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js index bafa8673..362c879e 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js +++ b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js @@ -9,7 +9,8 @@ module.exports = { 'boost': 100, 'query': 'test', 'type': 'phrase', - 'operator': 'and' + 'operator': 'and', + 'slop': 3 } } }], @@ -22,7 +23,8 @@ module.exports = { 'boost': 100, 'query': 'test', 'type': 'phrase', - 'operator': 'and' + 'operator': 'and', + 'slop': 3 } } }, @@ -41,7 +43,7 @@ module.exports = { 'weight': 40 }], 'score_mode': 'avg', - 'boost_mode': 'multiply', + 'boost_mode': 'replace', 'filter': { 'or': [ { @@ -60,12 +62,7 @@ module.exports = { },{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', @@ -82,12 +79,7 @@ module.exports = { },{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', diff --git a/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js b/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js index 17d3f064..450dbf87 100644 --- a/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js +++ b/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js @@ -20,7 +20,8 @@ module.exports = { 'boost': 100, 'query': 'three', 'type': 'phrase', - 'operator': 'and' + 'operator': 'and', + 'slop': 3 } } }], @@ -39,12 +40,7 @@ module.exports = { { 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one two three', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', @@ -61,12 +57,7 @@ module.exports = { },{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one two three', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', diff --git a/test/unit/fixture/autocomplete_linguistic_only.js b/test/unit/fixture/autocomplete_linguistic_only.js index 7ff675d9..fa32c80b 100644 --- a/test/unit/fixture/autocomplete_linguistic_only.js +++ b/test/unit/fixture/autocomplete_linguistic_only.js @@ -9,19 +9,15 @@ module.exports = { 'boost': 100, 'query': 'test', 'type': 'phrase', - 'operator': 'and' + 'operator': 'and', + 'slop': 3 } } }], 'should':[{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', @@ -38,12 +34,7 @@ module.exports = { },{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', diff --git a/test/unit/fixture/autocomplete_linguistic_with_admin.js b/test/unit/fixture/autocomplete_linguistic_with_admin.js index c5839e0f..2fcd25ca 100644 --- a/test/unit/fixture/autocomplete_linguistic_with_admin.js +++ b/test/unit/fixture/autocomplete_linguistic_with_admin.js @@ -102,12 +102,7 @@ module.exports = { { 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one two', - } - } + 'match_all': {} }, 'max_boost': 20, 'functions': [ @@ -127,12 +122,7 @@ module.exports = { { 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'one two', - } - } + 'match_all': {} }, 'max_boost': 20, 'functions': [ diff --git a/test/unit/fixture/autocomplete_single_character_street.js b/test/unit/fixture/autocomplete_single_character_street.js index 056e4554..356ef884 100644 --- a/test/unit/fixture/autocomplete_single_character_street.js +++ b/test/unit/fixture/autocomplete_single_character_street.js @@ -101,12 +101,7 @@ module.exports = { { 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'k road', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', @@ -123,12 +118,7 @@ module.exports = { },{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'k road', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', diff --git a/test/unit/fixture/autocomplete_with_source_filtering.js b/test/unit/fixture/autocomplete_with_source_filtering.js index f41299dd..0835f61f 100644 --- a/test/unit/fixture/autocomplete_with_source_filtering.js +++ b/test/unit/fixture/autocomplete_with_source_filtering.js @@ -9,19 +9,15 @@ module.exports = { 'boost': 100, 'query': 'test', 'type': 'phrase', - 'operator': 'and' + 'operator': 'and', + 'slop': 3 } } }], 'should':[{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', @@ -38,12 +34,7 @@ module.exports = { },{ 'function_score': { 'query': { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryFullToken', - 'query': 'test', - } - } + 'match_all': {} }, 'max_boost': 20, 'score_mode': 'first', diff --git a/test/unit/sanitiser/_tokenizer.js b/test/unit/sanitiser/_tokenizer.js index 8837d4ab..58d9cca8 100644 --- a/test/unit/sanitiser/_tokenizer.js +++ b/test/unit/sanitiser/_tokenizer.js @@ -372,8 +372,10 @@ module.exports.tests.final_token_single_gram = function(test, common) { 'grolmanstrasse', ], 'tokens produced'); - // last token removed! - t.deepEquals(clean.tokens_incomplete, [], 'no tokens'); + // last token marked as 'incomplete' + t.deepEquals(clean.tokens_incomplete, [ + 'a' + ], 'tokens produced'); // no errors/warnings produced t.deepEquals(messages.errors, [], 'no errors'); From d3cd14e304d33c91538c27fb6883661bf2f3b33d Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 30 Jun 2016 13:40:16 +0200 Subject: [PATCH 10/14] disable focus for single token queries, use constant_score for ngrams matching --- query/view/focus_selected_layers.js | 6 ++++++ query/view/ngrams_last_token_only.js | 6 +++++- .../fixture/autocomplete_linguistic_focus.js | 20 +++++++++++-------- ...tocomplete_linguistic_focus_null_island.js | 20 +++++++++++-------- ...autocomplete_linguistic_multiple_tokens.js | 20 +++++++++++-------- .../fixture/autocomplete_linguistic_only.js | 20 +++++++++++-------- .../autocomplete_with_source_filtering.js | 20 +++++++++++-------- 7 files changed, 71 insertions(+), 41 deletions(-) diff --git a/query/view/focus_selected_layers.js b/query/view/focus_selected_layers.js index ba19919f..9d23998c 100644 --- a/query/view/focus_selected_layers.js +++ b/query/view/focus_selected_layers.js @@ -14,6 +14,12 @@ var peliasQuery = require('pelias-query'); module.exports = function( subview ){ return function( vs ){ + // don't perform this query on single character inputs + // as its too unperformant to sort a large part of the index. + if( vs.var('input:name').get().length < 2 ){ + return null; + } + if( !subview ){ return null; } // subview validation failed var macroView = peliasQuery.view.focus( subview ); if( !macroView ){ return null; } // macroView validation failed diff --git a/query/view/ngrams_last_token_only.js b/query/view/ngrams_last_token_only.js index 2665c294..12be4584 100644 --- a/query/view/ngrams_last_token_only.js +++ b/query/view/ngrams_last_token_only.js @@ -28,5 +28,9 @@ module.exports = function( vs ){ vsCopy.var('input:name').set( tokens.join(' ') ); // return the view rendered using the copy - return ngrams_strict( vsCopy ); + return { + 'constant_score': { + 'query': ngrams_strict( vsCopy ) + } + }; }; diff --git a/test/unit/fixture/autocomplete_linguistic_focus.js b/test/unit/fixture/autocomplete_linguistic_focus.js index a9aea79d..07c741d7 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus.js +++ b/test/unit/fixture/autocomplete_linguistic_focus.js @@ -3,14 +3,18 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, - 'query': 'test', - 'type': 'phrase', - 'operator': 'and', - 'slop': 3 + 'constant_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryPartialToken', + 'boost': 100, + 'query': 'test', + 'type': 'phrase', + 'operator': 'and', + 'slop': 3 + } + } } } }], diff --git a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js index 362c879e..b0761f40 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js +++ b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js @@ -3,14 +3,18 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, - 'query': 'test', - 'type': 'phrase', - 'operator': 'and', - 'slop': 3 + 'constant_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryPartialToken', + 'boost': 100, + 'query': 'test', + 'type': 'phrase', + 'operator': 'and', + 'slop': 3 + } + } } } }], diff --git a/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js b/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js index 450dbf87..07a06d88 100644 --- a/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js +++ b/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js @@ -14,14 +14,18 @@ module.exports = { } }, { - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, - 'query': 'three', - 'type': 'phrase', - 'operator': 'and', - 'slop': 3 + 'constant_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryPartialToken', + 'boost': 100, + 'query': 'three', + 'type': 'phrase', + 'operator': 'and', + 'slop': 3 + } + } } } }], diff --git a/test/unit/fixture/autocomplete_linguistic_only.js b/test/unit/fixture/autocomplete_linguistic_only.js index fa32c80b..88a7d013 100644 --- a/test/unit/fixture/autocomplete_linguistic_only.js +++ b/test/unit/fixture/autocomplete_linguistic_only.js @@ -3,14 +3,18 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, - 'query': 'test', - 'type': 'phrase', - 'operator': 'and', - 'slop': 3 + 'constant_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryPartialToken', + 'boost': 100, + 'query': 'test', + 'type': 'phrase', + 'operator': 'and', + 'slop': 3 + } + } } } }], diff --git a/test/unit/fixture/autocomplete_with_source_filtering.js b/test/unit/fixture/autocomplete_with_source_filtering.js index 0835f61f..cebd7eea 100644 --- a/test/unit/fixture/autocomplete_with_source_filtering.js +++ b/test/unit/fixture/autocomplete_with_source_filtering.js @@ -3,14 +3,18 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'name.default': { - 'analyzer': 'peliasQueryPartialToken', - 'boost': 100, - 'query': 'test', - 'type': 'phrase', - 'operator': 'and', - 'slop': 3 + 'constant_score': { + 'query': { + 'match': { + 'name.default': { + 'analyzer': 'peliasQueryPartialToken', + 'boost': 100, + 'query': 'test', + 'type': 'phrase', + 'operator': 'and', + 'slop': 3 + } + } } } }], From 5964e57faab200eed4fe9eabb80b18d4d479b174 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 30 Jun 2016 15:28:23 +0200 Subject: [PATCH 11/14] change ngram analyzer used in /search to peliasQueryFullToken from peliasIndexOneEdgeGram. this will have a positive effect on performance due to less tokens being produced --- query/search_defaults.js | 2 +- test/unit/fixture/search_boundary_country.js | 2 +- test/unit/fixture/search_full_address.js | 2 +- test/unit/fixture/search_linguistic_bbox.js | 2 +- test/unit/fixture/search_linguistic_focus.js | 2 +- test/unit/fixture/search_linguistic_focus_bbox.js | 2 +- test/unit/fixture/search_linguistic_focus_null_island.js | 2 +- test/unit/fixture/search_linguistic_only.js | 2 +- test/unit/fixture/search_linguistic_viewport.js | 2 +- test/unit/fixture/search_linguistic_viewport_min_diagonal.js | 2 +- test/unit/fixture/search_partial_address.js | 2 +- test/unit/fixture/search_regions_address.js | 2 +- test/unit/fixture/search_with_source_filtering.js | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/query/search_defaults.js b/query/search_defaults.js index 4f77bccc..4e6a7ffb 100644 --- a/query/search_defaults.js +++ b/query/search_defaults.js @@ -18,7 +18,7 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'boundary:rect:type': 'indexed', - 'ngram:analyzer': 'peliasIndexOneEdgeGram', + 'ngram:analyzer': 'peliasQueryFullToken', 'ngram:field': 'name.default', 'ngram:boost': 1, diff --git a/test/unit/fixture/search_boundary_country.js b/test/unit/fixture/search_boundary_country.js index 37d31c3b..6af4e840 100644 --- a/test/unit/fixture/search_boundary_country.js +++ b/test/unit/fixture/search_boundary_country.js @@ -16,7 +16,7 @@ module.exports = { 'name.default': { 'query': 'test', 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'analyzer': 'peliasQueryFullToken' } } } diff --git a/test/unit/fixture/search_full_address.js b/test/unit/fixture/search_full_address.js index 5ebb0004..6af4b35b 100644 --- a/test/unit/fixture/search_full_address.js +++ b/test/unit/fixture/search_full_address.js @@ -7,7 +7,7 @@ module.exports = { 'match': { 'name.default': { 'query': '123 main st', - 'analyzer': 'peliasIndexOneEdgeGram', + 'analyzer': 'peliasQueryFullToken', 'boost': 1 } } diff --git a/test/unit/fixture/search_linguistic_bbox.js b/test/unit/fixture/search_linguistic_bbox.js index 8a9b7849..0a8f5ddc 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -7,7 +7,7 @@ module.exports = { 'name.default': { 'query': 'test', 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'analyzer': 'peliasQueryFullToken' } } }], diff --git a/test/unit/fixture/search_linguistic_focus.js b/test/unit/fixture/search_linguistic_focus.js index 72c0570d..e3c027c1 100644 --- a/test/unit/fixture/search_linguistic_focus.js +++ b/test/unit/fixture/search_linguistic_focus.js @@ -7,7 +7,7 @@ module.exports = { 'name.default': { 'query': 'test', 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'analyzer': 'peliasQueryFullToken' } } }], diff --git a/test/unit/fixture/search_linguistic_focus_bbox.js b/test/unit/fixture/search_linguistic_focus_bbox.js index 23de4cf9..a185ea73 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -7,7 +7,7 @@ module.exports = { 'name.default': { 'query': 'test', 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'analyzer': 'peliasQueryFullToken' } } }], diff --git a/test/unit/fixture/search_linguistic_focus_null_island.js b/test/unit/fixture/search_linguistic_focus_null_island.js index 6704b96e..152a0c42 100644 --- a/test/unit/fixture/search_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_linguistic_focus_null_island.js @@ -7,7 +7,7 @@ module.exports = { 'name.default': { 'query': 'test', 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'analyzer': 'peliasQueryFullToken' } } }], diff --git a/test/unit/fixture/search_linguistic_only.js b/test/unit/fixture/search_linguistic_only.js index d0e02c16..2e820c80 100644 --- a/test/unit/fixture/search_linguistic_only.js +++ b/test/unit/fixture/search_linguistic_only.js @@ -7,7 +7,7 @@ module.exports = { 'name.default': { 'query': 'test', 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'analyzer': 'peliasQueryFullToken' } } }], diff --git a/test/unit/fixture/search_linguistic_viewport.js b/test/unit/fixture/search_linguistic_viewport.js index fdaa91a0..4f225a62 100644 --- a/test/unit/fixture/search_linguistic_viewport.js +++ b/test/unit/fixture/search_linguistic_viewport.js @@ -5,7 +5,7 @@ module.exports = { { 'match': { 'name.default': { - 'analyzer': 'peliasIndexOneEdgeGram', + 'analyzer': 'peliasQueryFullToken', 'boost': 1, 'query': 'test' } diff --git a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js index 67962109..e5dbb862 100644 --- a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js +++ b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js @@ -7,7 +7,7 @@ module.exports = { { 'match': { 'name.default': { - 'analyzer': 'peliasIndexOneEdgeGram', + 'analyzer': 'peliasQueryFullToken', 'boost': 1, 'query': 'test' } diff --git a/test/unit/fixture/search_partial_address.js b/test/unit/fixture/search_partial_address.js index 47acb4ac..ec8ff4ea 100644 --- a/test/unit/fixture/search_partial_address.js +++ b/test/unit/fixture/search_partial_address.js @@ -8,7 +8,7 @@ module.exports = { 'match': { 'name.default': { 'query': 'soho grand', - 'analyzer': 'peliasIndexOneEdgeGram', + 'analyzer': 'peliasQueryFullToken', 'boost': 1 } } diff --git a/test/unit/fixture/search_regions_address.js b/test/unit/fixture/search_regions_address.js index a133da38..cf65b199 100644 --- a/test/unit/fixture/search_regions_address.js +++ b/test/unit/fixture/search_regions_address.js @@ -8,7 +8,7 @@ module.exports = { 'match': { 'name.default': { 'query': '1 water st', - 'analyzer': 'peliasIndexOneEdgeGram', + 'analyzer': 'peliasQueryFullToken', 'boost': 1 } } diff --git a/test/unit/fixture/search_with_source_filtering.js b/test/unit/fixture/search_with_source_filtering.js index 8feb6820..24da9468 100644 --- a/test/unit/fixture/search_with_source_filtering.js +++ b/test/unit/fixture/search_with_source_filtering.js @@ -7,7 +7,7 @@ module.exports = { 'name.default': { 'query': 'test', 'boost': 1, - 'analyzer': 'peliasIndexOneEdgeGram' + 'analyzer': 'peliasQueryFullToken' } } }], From 35e548ef159f33f99fe0c941225cabd5439cc624 Mon Sep 17 00:00:00 2001 From: Alec Vulfson Date: Thu, 30 Jun 2016 14:46:49 -0400 Subject: [PATCH 12/14] Updating list of layers for Geonames --- helper/type_mapping.js | 3 ++- test/unit/sanitiser/_sources_and_layers.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/helper/type_mapping.js b/helper/type_mapping.js index ed20c0d8..59dbb590 100644 --- a/helper/type_mapping.js +++ b/helper/type_mapping.js @@ -47,7 +47,8 @@ var SOURCE_MAPPING = addStandardTargetsToAliases(SOURCES, SOURCE_ALIASES); var LAYERS_BY_SOURCE = { openstreetmap: [ 'address', 'venue' ], openaddresses: [ 'address' ], - geonames: [ 'country', 'region', 'county', 'locality', 'venue' ], + geonames: [ 'country','macroregion', 'region', 'county','localadmin', + 'locality', 'neighbourhood', 'venue' ], whosonfirst: [ 'continent', 'country', 'dependency', 'macroregion', 'region', 'locality', 'localadmin', 'macrocounty', 'county', 'macrohood', 'borough', 'neighbourhood', 'microhood', 'disputed'] diff --git a/test/unit/sanitiser/_sources_and_layers.js b/test/unit/sanitiser/_sources_and_layers.js index 96001f4e..dfb997fa 100644 --- a/test/unit/sanitiser/_sources_and_layers.js +++ b/test/unit/sanitiser/_sources_and_layers.js @@ -51,6 +51,17 @@ module.exports.tests.no_errors = function(test, common) { t.end(); }); +test('valid combination', function(t) { + var raw = {}; + var clean = { sources: ['geonames'], layers: ['macroregion'] }; + + var messages = sanitize(raw, clean); + + t.equal(messages.errors.length, 0, 'should return no errors'); + t.equal(messages.warnings.length, 0, 'should return no warnings'); + t.end(); + }); + test('valid combination because of multiple sources', function(t) { var raw = {}; var clean = { sources: ['openstreetmap', 'openaddresses'], layers: ['venue'] }; From 6b47e4bc5221844f5b76e44f9714a8784bce1b1c Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 30 Jun 2016 15:38:10 -0400 Subject: [PATCH 13/14] Update pelias-query to 8.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 012f1e6e..ad8dd4b1 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "pelias-config": "git://github.com/pelias/config.git#elasticsearch2", "pelias-logger": "^0.0.8", "pelias-model": "^4.0.0", - "pelias-query": "git://github.com/pelias/query.git#elasticsearch2", + "pelias-query": "~8.0.0", "pelias-suggester-pipeline": "2.0.4", "pelias-text-analyzer": "^1.0.1", "stats-lite": "1.0.3", From 675233c9c416fe6cf638ad7fa7546d2f13b0aeab Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 30 Jun 2016 15:38:34 -0400 Subject: [PATCH 14/14] Update pelias-config to 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad8dd4b1..1099a2cb 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "lodash": "^4.5.0", "markdown": "0.5.0", "morgan": "1.7.0", - "pelias-config": "git://github.com/pelias/config.git#elasticsearch2", + "pelias-config": "~2.0.0", "pelias-logger": "^0.0.8", "pelias-model": "^4.0.0", "pelias-query": "~8.0.0",