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(); });