From 601478616207915211143fe1db0421acd4b5d844 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Wed, 19 Apr 2017 17:44:03 -0400 Subject: [PATCH] =?UTF-8?q?Revert=20"Update=20pelias-query=20to=20the=20la?= =?UTF-8?q?test=20version=20=F0=9F=9A=80"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- test/unit/fixture/search_boundary_country.js | 40 +- test/unit/fixture/search_fallback.js | 1593 ++++++++-------- .../search_fallback_postalcode_only.js | 49 +- test/unit/fixture/search_linguistic_bbox.js | 40 +- test/unit/fixture/search_linguistic_focus.js | 40 +- .../fixture/search_linguistic_focus_bbox.js | 40 +- .../search_linguistic_focus_null_island.js | 40 +- test/unit/fixture/search_linguistic_only.js | 40 +- .../fixture/search_linguistic_viewport.js | 40 +- ...search_linguistic_viewport_min_diagonal.js | 40 +- .../fixture/search_with_category_filtering.js | 40 +- .../fixture/search_with_source_filtering.js | 40 +- .../boundary_country.json | 10 +- .../structured_geocoding/fallback.json | 1595 +++++++++-------- .../structured_geocoding/linguistic_bbox.json | 10 +- .../linguistic_focus.json | 10 +- .../linguistic_focus_bbox.json | 8 +- .../linguistic_focus_null_island.json | 10 +- .../structured_geocoding/linguistic_only.json | 10 +- .../linguistic_viewport.json | 10 +- .../linguistic_viewport_min_diagonal.json | 10 +- .../structured_geocoding/postalcode_only.js | 49 +- .../with_source_filtering.json | 11 +- 24 files changed, 1944 insertions(+), 1833 deletions(-) diff --git a/package.json b/package.json index 68d37222..730b3a54 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "pelias-logger": "0.2.0", "pelias-mock-logger": "^1.0.1", "pelias-model": "4.6.0", - "pelias-query": "8.16.0", + "pelias-query": "8.15.0", "pelias-text-analyzer": "1.7.3", "predicates": "^1.0.1", "retry": "^0.10.1", diff --git a/test/unit/fixture/search_boundary_country.js b/test/unit/fixture/search_boundary_country.js index e03a2b8b..ee6427a0 100644 --- a/test/unit/fixture/search_boundary_country.js +++ b/test/unit/fixture/search_boundary_country.js @@ -2,28 +2,32 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + } + ], + 'should': [], + 'filter': { + 'term': { + 'layer': 'street' + } } } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } } - } + ] } - ], + }, 'filter': { 'bool': { 'must': [ diff --git a/test/unit/fixture/search_fallback.js b/test/unit/fixture/search_fallback.js index 86c477f0..3835cadb 100644 --- a/test/unit/fixture/search_fallback.js +++ b/test/unit/fixture/search_fallback.js @@ -2,828 +2,837 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.venue', - 'must': [ - { - 'multi_match': { - 'query': 'query value', - 'type': 'phrase', - 'fields': [ - 'phrase.default' - ] + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.venue', + 'must': [ + { + 'multi_match': { + 'query': 'query value', + 'type': 'phrase', + 'fields': [ + 'phrase.default' + ] + } + }, + { + 'multi_match': { + 'query': 'neighbourhood value', + 'type': 'phrase', + 'fields': [ + 'parent.neighbourhood', + 'parent.neighbourhood_a' + ] + } + }, + { + 'multi_match': { + 'query': 'borough value', + 'type': 'phrase', + 'fields': [ + 'parent.borough', + 'parent.borough_a' + ] + } + }, + { + 'multi_match': { + 'query': 'city value', + 'type': 'phrase', + 'fields': [ + 'parent.locality', + 'parent.locality_a', + 'parent.localadmin', + 'parent.localadmin_a' + ] + } + }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a', + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'venue' + } } - }, - { - 'multi_match': { - 'query': 'neighbourhood value', - 'type': 'phrase', - 'fields': [ - 'parent.neighbourhood', - 'parent.neighbourhood_a' - ] - } - }, - { - 'multi_match': { - 'query': 'borough value', - 'type': 'phrase', - 'fields': [ - 'parent.borough', - 'parent.borough_a' - ] - } - }, - { - 'multi_match': { - 'query': 'city value', - 'type': 'phrase', - 'fields': [ - 'parent.locality', - 'parent.locality_a', - 'parent.localadmin', - 'parent.localadmin_a' - ] - } - }, - { - 'multi_match': { - 'query': 'county value', - 'type': 'phrase', - 'fields': [ - 'parent.county', - 'parent.county_a', - 'parent.macrocounty', - 'parent.macrocounty_a' - ] - } - }, - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a', - 'parent.macroregion', - 'parent.macroregion_a' - ] - } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'venue' } - } - } - }, - { - 'bool': { - '_name': 'fallback.address', - 'boost': 10, - 'must': [ - { - 'match_phrase': { - 'address_parts.number': 'number value' - } - }, - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - }, - { - 'multi_match': { - 'query': 'neighbourhood value', - 'type': 'phrase', - 'fields': [ - 'parent.neighbourhood', - 'parent.neighbourhood_a' - ] - } - }, - { - 'multi_match': { - 'query': 'borough value', - 'type': 'phrase', - 'fields': [ - 'parent.borough', - 'parent.borough_a' - ] - } - }, - { - 'multi_match': { - 'query': 'city value', - 'type': 'phrase', - 'fields': [ - 'parent.locality', - 'parent.locality_a', - 'parent.localadmin', - 'parent.localadmin_a' - ] - } - }, - { - 'multi_match': { - 'query': 'county value', - 'type': 'phrase', - 'fields': [ - 'parent.county', - 'parent.county_a', - 'parent.macrocounty', - 'parent.macrocounty_a' - ] - } - }, - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a', - 'parent.macroregion', - 'parent.macroregion_a' - ] - } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] + }, + { + 'bool': { + '_name': 'fallback.address', + 'boost': 10, + 'must': [ + { + 'match_phrase': { + 'address_parts.number': 'number value' + } + }, + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + }, + { + 'multi_match': { + 'query': 'neighbourhood value', + 'type': 'phrase', + 'fields': [ + 'parent.neighbourhood', + 'parent.neighbourhood_a' + ] + } + }, + { + 'multi_match': { + 'query': 'borough value', + 'type': 'phrase', + 'fields': [ + 'parent.borough', + 'parent.borough_a' + ] + } + }, + { + 'multi_match': { + 'query': 'city value', + 'type': 'phrase', + 'fields': [ + 'parent.locality', + 'parent.locality_a', + 'parent.localadmin', + 'parent.localadmin_a' + ] + } + }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a', + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'should': [ + { + 'match_phrase': { + 'address_parts.zip': 'postalcode value' + } + } + ], + 'filter': { + 'term': { + 'layer': 'address' + } } } - ], - 'should': [ - { - 'match_phrase': { - 'address_parts.zip': 'postalcode value' + }, + { + 'bool': { + '_name': 'fallback.postalcode', + 'must': [ + { + 'multi_match': { + 'query': 'postalcode value', + 'type': 'phrase', + 'fields': [ + 'parent.postalcode' + ] + } + }, + { + 'multi_match': { + 'query': 'city value', + 'type': 'phrase', + 'fields': [ + 'parent.locality', + 'parent.locality_a', + 'parent.localadmin', + 'parent.localadmin_a' + ] + } + }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a', + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'postalcode' + } } } - ], - 'filter': { - 'term': { - 'layer': 'address' - } - } - } - }, - { - 'bool': { - '_name': 'fallback.postalcode', - 'must': [ - { - 'multi_match': { - 'query': 'postalcode value', - 'type': 'phrase', - 'fields': [ - 'parent.postalcode' - ] - } - }, - { - 'multi_match': { - 'query': 'city value', - 'type': 'phrase', - 'fields': [ - 'parent.locality', - 'parent.locality_a', - 'parent.localadmin', - 'parent.localadmin_a' - ] - } - }, - { - 'multi_match': { - 'query': 'county value', - 'type': 'phrase', - 'fields': [ - 'parent.county', - 'parent.county_a', - 'parent.macrocounty', - 'parent.macrocounty_a' - ] - } - }, - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a', - 'parent.macroregion', - 'parent.macroregion_a' - ] + }, + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + }, + { + 'multi_match': { + 'query': 'neighbourhood value', + 'type': 'phrase', + 'fields': [ + 'parent.neighbourhood', + 'parent.neighbourhood_a' + ] + } + }, + { + 'multi_match': { + 'query': 'borough value', + 'type': 'phrase', + 'fields': [ + 'parent.borough', + 'parent.borough_a' + ] + } + }, + { + 'multi_match': { + 'query': 'city value', + 'type': 'phrase', + 'fields': [ + 'parent.locality', + 'parent.locality_a', + 'parent.localadmin', + 'parent.localadmin_a' + ] + } + }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a', + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'should': [ + { + 'match_phrase': { + 'address_parts.zip': 'postalcode value' + } + } + ], + 'filter': { + 'term': { + 'layer': 'street' + } } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'postalcode' } - } - } - }, - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - }, - { - 'multi_match': { - 'query': 'neighbourhood value', - 'type': 'phrase', - 'fields': [ - 'parent.neighbourhood', - 'parent.neighbourhood_a' - ] - } - }, - { - 'multi_match': { - 'query': 'borough value', - 'type': 'phrase', - 'fields': [ - 'parent.borough', - 'parent.borough_a' - ] - } - }, - { - 'multi_match': { - 'query': 'city value', - 'type': 'phrase', - 'fields': [ - 'parent.locality', - 'parent.locality_a', - 'parent.localadmin', - 'parent.localadmin_a' - ] - } - }, - { - 'multi_match': { - 'query': 'county value', - 'type': 'phrase', - 'fields': [ - 'parent.county', - 'parent.county_a', - 'parent.macrocounty', - 'parent.macrocounty_a' - ] - } - }, - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a', - 'parent.macroregion', - 'parent.macroregion_a' - ] - } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] + }, + { + 'bool': { + '_name': 'fallback.neighbourhood', + 'must': [ + { + 'multi_match': { + 'query': 'neighbourhood value', + 'type': 'phrase', + 'fields': [ + 'parent.neighbourhood', + 'parent.neighbourhood_a' + ] + } + }, + { + 'multi_match': { + 'query': 'borough value', + 'type': 'phrase', + 'fields': [ + 'parent.borough', + 'parent.borough_a' + ] + } + }, + { + 'multi_match': { + 'query': 'city value', + 'type': 'phrase', + 'fields': [ + 'parent.locality', + 'parent.locality_a', + 'parent.localadmin', + 'parent.localadmin_a' + ] + } + }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a', + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'neighbourhood' + } } } - ], - 'should': [ - { - 'match_phrase': { - 'address_parts.zip': 'postalcode value' + }, + { + 'bool': { + '_name': 'fallback.borough', + 'must': [ + { + 'multi_match': { + 'query': 'borough value', + 'type': 'phrase', + 'fields': [ + 'parent.borough', + 'parent.borough_a' + ] + } + }, + { + 'multi_match': { + 'query': 'city value', + 'type': 'phrase', + 'fields': [ + 'parent.locality', + 'parent.locality_a', + 'parent.localadmin', + 'parent.localadmin_a' + ] + } + }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a', + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'borough' + } } } - ], - 'filter': { - 'term': { - 'layer': 'street' - } - } - } - }, - { - 'bool': { - '_name': 'fallback.neighbourhood', - 'must': [ - { - 'multi_match': { - 'query': 'neighbourhood value', - 'type': 'phrase', - 'fields': [ - 'parent.neighbourhood', - 'parent.neighbourhood_a' - ] - } - }, - { - 'multi_match': { - 'query': 'borough value', - 'type': 'phrase', - 'fields': [ - 'parent.borough', - 'parent.borough_a' - ] - } - }, - { - 'multi_match': { - 'query': 'city value', - 'type': 'phrase', - 'fields': [ - 'parent.locality', - 'parent.locality_a', - 'parent.localadmin', - 'parent.localadmin_a' - ] - } - }, - { - 'multi_match': { - 'query': 'county value', - 'type': 'phrase', - 'fields': [ - 'parent.county', - 'parent.county_a', - 'parent.macrocounty', - 'parent.macrocounty_a' - ] - } - }, - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a', - 'parent.macroregion', - 'parent.macroregion_a' - ] + }, + { + 'bool': { + '_name': 'fallback.locality', + 'must': [ + { + 'multi_match': { + 'query': 'city value', + 'type': 'phrase', + 'fields': [ + 'parent.locality', + 'parent.locality_a' + ] + } + }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a', + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'locality' + } } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'neighbourhood' } - } - } - }, - { - 'bool': { - '_name': 'fallback.borough', - 'must': [ - { - 'multi_match': { - 'query': 'borough value', - 'type': 'phrase', - 'fields': [ - 'parent.borough', - 'parent.borough_a' - ] - } - }, - { - 'multi_match': { - 'query': 'city value', - 'type': 'phrase', - 'fields': [ - 'parent.locality', - 'parent.locality_a', - 'parent.localadmin', - 'parent.localadmin_a' - ] - } - }, - { - 'multi_match': { - 'query': 'county value', - 'type': 'phrase', - 'fields': [ - 'parent.county', - 'parent.county_a', - 'parent.macrocounty', - 'parent.macrocounty_a' - ] - } - }, - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a', - 'parent.macroregion', - 'parent.macroregion_a' - ] - } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'borough' - } - } - } - }, - { - 'bool': { - '_name': 'fallback.locality', - 'must': [ - { - 'multi_match': { - 'query': 'city value', - 'type': 'phrase', - 'fields': [ - 'parent.locality', - 'parent.locality_a' - ] - } - }, - { - 'multi_match': { - 'query': 'county value', - 'type': 'phrase', - 'fields': [ - 'parent.county', - 'parent.county_a', - 'parent.macrocounty', - 'parent.macrocounty_a' - ] - } - }, - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a', - 'parent.macroregion', - 'parent.macroregion_a' - ] - } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] + }, + { + 'bool': { + '_name': 'fallback.localadmin', + 'must': [ + { + 'multi_match': { + 'query': 'city value', + 'type': 'phrase', + 'fields': [ + 'parent.localadmin', + 'parent.localadmin_a' + ] + } + }, + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a', + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a', + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'localadmin' + } } } - ], - 'filter': { - 'term': { - 'layer': 'locality' - } - } - } - }, - { - 'bool': { - '_name': 'fallback.localadmin', - 'must': [ - { - 'multi_match': { - 'query': 'city value', - 'type': 'phrase', - 'fields': [ - 'parent.localadmin', - 'parent.localadmin_a' - ] - } - }, - { - 'multi_match': { - 'query': 'county value', - 'type': 'phrase', - 'fields': [ - 'parent.county', - 'parent.county_a', - 'parent.macrocounty', - 'parent.macrocounty_a' - ] - } - }, - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a', - 'parent.macroregion', - 'parent.macroregion_a' - ] - } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'localadmin' - } - } - } - }, - { - 'bool': { - '_name': 'fallback.county', - 'must': [ - { - 'multi_match': { - 'query': 'county value', - 'type': 'phrase', - 'fields': [ - 'parent.county', - 'parent.county_a' - ] + }, + { + 'bool': { + '_name': 'fallback.county', + 'must': [ + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.county', + 'parent.county_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a', + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'county' + } } - }, - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a', - 'parent.macroregion', - 'parent.macroregion_a' - ] - } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'county' } - } - } - }, - { - 'bool': { - '_name': 'fallback.macrocounty', - 'must': [ - { - 'multi_match': { - 'query': 'county value', - 'type': 'phrase', - 'fields': [ - 'parent.macrocounty', - 'parent.macrocounty_a' - ] - } - }, - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a', - 'parent.macroregion', - 'parent.macroregion_a' - ] + }, + { + 'bool': { + '_name': 'fallback.macrocounty', + 'must': [ + { + 'multi_match': { + 'query': 'county value', + 'type': 'phrase', + 'fields': [ + 'parent.macrocounty', + 'parent.macrocounty_a' + ] + } + }, + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a', + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'macrocounty' + } } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'macrocounty' } - } - } - }, - { - 'bool': { - '_name': 'fallback.region', - 'must': [ - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.region', - 'parent.region_a' - ] + }, + { + 'bool': { + '_name': 'fallback.region', + 'must': [ + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.region', + 'parent.region_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'region' + } } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'region' } - } - } - }, - { - 'bool': { - '_name': 'fallback.macroregion', - 'must': [ - { - 'multi_match': { - 'query': 'state value', - 'type': 'phrase', - 'fields': [ - 'parent.macroregion', - 'parent.macroregion_a' - ] - } - }, - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a', - 'parent.dependency', - 'parent.dependency_a' - ] + }, + { + 'bool': { + '_name': 'fallback.macroregion', + 'must': [ + { + 'multi_match': { + 'query': 'state value', + 'type': 'phrase', + 'fields': [ + 'parent.macroregion', + 'parent.macroregion_a' + ] + } + }, + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a', + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'macroregion' + } } } - ], - 'filter': { - 'term': { - 'layer': 'macroregion' - } - } - } - }, - { - 'bool': { - '_name': 'fallback.dependency', - 'must': [ - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.dependency', - 'parent.dependency_a' - ] + }, + { + 'bool': { + '_name': 'fallback.dependency', + 'must': [ + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.dependency', + 'parent.dependency_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'dependency' + } } } - ], - 'filter': { - 'term': { - 'layer': 'dependency' - } - } - } - }, - { - 'bool': { - '_name': 'fallback.country', - 'must': [ - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a' - ] + }, + { + 'bool': { + '_name': 'fallback.country', + 'must': [ + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'country' + } } } - ], - 'filter': { - 'term': { - 'layer': 'country' - } } - } + ] + } + }, + 'filter': { + 'bool': { + 'must': [] } - ] + } } }, 'max_boost': 20, diff --git a/test/unit/fixture/search_fallback_postalcode_only.js b/test/unit/fixture/search_fallback_postalcode_only.js index c2c296e7..4519e166 100644 --- a/test/unit/fixture/search_fallback_postalcode_only.js +++ b/test/unit/fixture/search_fallback_postalcode_only.js @@ -2,30 +2,39 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.postalcode', - 'must': [ - { - 'multi_match': { - 'query': '90210', - 'type': 'phrase', - 'fields': [ - 'parent.postalcode' - ] + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.postalcode', + 'must': [ + { + 'multi_match': { + 'query': '90210', + 'type': 'phrase', + 'fields': [ + 'parent.postalcode' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'postalcode' + } } } - ], - 'filter': { - 'term': { - 'layer': 'postalcode' - } } - } + ] + } + }, + 'filter': { + 'bool': { + 'must': [] } - ] + } } }, 'max_boost': 20, diff --git a/test/unit/fixture/search_linguistic_bbox.js b/test/unit/fixture/search_linguistic_bbox.js index 9e02cbc4..e74f6c79 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -2,28 +2,32 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + } + ], + 'should': [], + 'filter': { + 'term': { + 'layer': 'street' + } } } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } } - } + ] } - ], + }, 'filter': { 'bool': { 'must': [ diff --git a/test/unit/fixture/search_linguistic_focus.js b/test/unit/fixture/search_linguistic_focus.js index 218dbbb1..a63400b3 100644 --- a/test/unit/fixture/search_linguistic_focus.js +++ b/test/unit/fixture/search_linguistic_focus.js @@ -2,28 +2,32 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + } + ], + 'should': [], + 'filter': { + 'term': { + 'layer': 'street' + } } } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } } - } + ] } - ], + }, 'filter': { 'bool': { 'must': [ diff --git a/test/unit/fixture/search_linguistic_focus_bbox.js b/test/unit/fixture/search_linguistic_focus_bbox.js index 88ee6d68..7f6c8528 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -2,28 +2,32 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + } + ], + 'should': [], + 'filter': { + 'term': { + 'layer': 'street' + } } } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } } - } + ] } - ], + }, 'filter': { 'bool': { 'must': [ diff --git a/test/unit/fixture/search_linguistic_focus_null_island.js b/test/unit/fixture/search_linguistic_focus_null_island.js index 8603a1db..da12154a 100644 --- a/test/unit/fixture/search_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_linguistic_focus_null_island.js @@ -2,28 +2,32 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + } + ], + 'should': [], + 'filter': { + 'term': { + 'layer': 'street' + } } } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } } - } + ] } - ], + }, 'filter': { 'bool': { 'must': [ diff --git a/test/unit/fixture/search_linguistic_only.js b/test/unit/fixture/search_linguistic_only.js index c99d4eff..0117e03b 100644 --- a/test/unit/fixture/search_linguistic_only.js +++ b/test/unit/fixture/search_linguistic_only.js @@ -2,28 +2,32 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + } + ], + 'should': [], + 'filter': { + 'term': { + 'layer': 'street' + } } } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } } - } + ] } - ], + }, 'filter': { 'bool': { 'must': [ diff --git a/test/unit/fixture/search_linguistic_viewport.js b/test/unit/fixture/search_linguistic_viewport.js index c99d4eff..0117e03b 100644 --- a/test/unit/fixture/search_linguistic_viewport.js +++ b/test/unit/fixture/search_linguistic_viewport.js @@ -2,28 +2,32 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + } + ], + 'should': [], + 'filter': { + 'term': { + 'layer': 'street' + } } } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } } - } + ] } - ], + }, 'filter': { 'bool': { 'must': [ diff --git a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js index c99d4eff..0117e03b 100644 --- a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js +++ b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js @@ -2,28 +2,32 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + } + ], + 'should': [], + 'filter': { + 'term': { + 'layer': 'street' + } } } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } } - } + ] } - ], + }, 'filter': { 'bool': { 'must': [ diff --git a/test/unit/fixture/search_with_category_filtering.js b/test/unit/fixture/search_with_category_filtering.js index 0ea7fc93..05f9ec4e 100644 --- a/test/unit/fixture/search_with_category_filtering.js +++ b/test/unit/fixture/search_with_category_filtering.js @@ -2,28 +2,32 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + } + ], + 'should': [], + 'filter': { + 'term': { + 'layer': 'street' + } } } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } } - } + ] } - ], + }, 'filter': { 'bool': { 'must': [ diff --git a/test/unit/fixture/search_with_source_filtering.js b/test/unit/fixture/search_with_source_filtering.js index efccbe52..0e9010c2 100644 --- a/test/unit/fixture/search_with_source_filtering.js +++ b/test/unit/fixture/search_with_source_filtering.js @@ -2,28 +2,32 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' + } + } + ], + 'should': [], + 'filter': { + 'term': { + 'layer': 'street' + } } } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } } - } + ] } - ], + }, 'filter': { 'bool': { 'must': [ diff --git a/test/unit/fixture/structured_geocoding/boundary_country.json b/test/unit/fixture/structured_geocoding/boundary_country.json index 9a73c22d..182da5a9 100644 --- a/test/unit/fixture/structured_geocoding/boundary_country.json +++ b/test/unit/fixture/structured_geocoding/boundary_country.json @@ -2,8 +2,12 @@ "query": { "function_score": { "query": { - "bool": { - "should": [], + "filtered": { + "query": { + "bool": { + "should": [] + } + }, "filter": { "bool": { "must": [ @@ -55,4 +59,4 @@ ], "size": 10, "track_scores": true -} +} \ No newline at end of file diff --git a/test/unit/fixture/structured_geocoding/fallback.json b/test/unit/fixture/structured_geocoding/fallback.json index 92c2674d..58d0ce8c 100644 --- a/test/unit/fixture/structured_geocoding/fallback.json +++ b/test/unit/fixture/structured_geocoding/fallback.json @@ -2,829 +2,838 @@ "query": { "function_score": { "query": { - "bool": { - "should": [ - { - "bool": { - "_name": "fallback.venue", - "must": [ - { - "multi_match": { - "query": "query value", - "type": "phrase", - "fields": [ - "phrase.default", - "category" - ] - } - }, - { - "multi_match": { - "query": "neighbourhood value", - "type": "phrase", - "fields": [ - "parent.neighbourhood", - "parent.neighbourhood_a" - ] - } - }, - { - "multi_match": { - "query": "borough value", - "type": "phrase", - "fields": [ - "parent.borough", - "parent.borough_a" - ] - } - }, - { - "multi_match": { - "query": "city value", - "type": "phrase", - "fields": [ - "parent.locality", - "parent.locality_a", - "parent.localadmin", - "parent.localadmin_a" - ] - } - }, - { - "multi_match": { - "query": "county value", - "type": "phrase", - "fields": [ - "parent.county", - "parent.county_a", - "parent.macrocounty", - "parent.macrocounty_a" - ] - } - }, - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a", - "parent.macroregion", - "parent.macroregion_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] - } - } - ], - "filter": { - "term": { - "layer": "venue" - } - } - } - }, - { - "bool": { - "_name": "fallback.address", - "must": [ - { - "match_phrase": { - "address_parts.number": "number value" - } - }, - { - "match_phrase": { - "address_parts.street": "street value" - } - }, - { - "multi_match": { - "query": "neighbourhood value", - "type": "phrase", - "fields": [ - "parent.neighbourhood", - "parent.neighbourhood_a" - ] - } - }, - { - "multi_match": { - "query": "borough value", - "type": "phrase", - "fields": [ - "parent.borough", - "parent.borough_a" - ] - } - }, - { - "multi_match": { - "query": "city value", - "type": "phrase", - "fields": [ - "parent.locality", - "parent.locality_a", - "parent.localadmin", - "parent.localadmin_a" - ] - } - }, - { - "multi_match": { - "query": "county value", - "type": "phrase", - "fields": [ - "parent.county", - "parent.county_a", - "parent.macrocounty", - "parent.macrocounty_a" - ] - } - }, - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a", - "parent.macroregion", - "parent.macroregion_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] + "filtered": { + "query": { + "bool": { + "should": [ + { + "bool": { + "_name": "fallback.venue", + "must": [ + { + "multi_match": { + "query": "query value", + "type": "phrase", + "fields": [ + "phrase.default", + "category" + ] + } + }, + { + "multi_match": { + "query": "neighbourhood value", + "type": "phrase", + "fields": [ + "parent.neighbourhood", + "parent.neighbourhood_a" + ] + } + }, + { + "multi_match": { + "query": "borough value", + "type": "phrase", + "fields": [ + "parent.borough", + "parent.borough_a" + ] + } + }, + { + "multi_match": { + "query": "city value", + "type": "phrase", + "fields": [ + "parent.locality", + "parent.locality_a", + "parent.localadmin", + "parent.localadmin_a" + ] + } + }, + { + "multi_match": { + "query": "county value", + "type": "phrase", + "fields": [ + "parent.county", + "parent.county_a", + "parent.macrocounty", + "parent.macrocounty_a" + ] + } + }, + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a", + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "venue" + } } } - ], - "should": [ - { - "match_phrase": { - "address_parts.zip": "postalcode value" - } - } - ], - "filter": { - "term": { - "layer": "address" - } }, - "boost": 10 - } - }, - { - "bool": { - "_name": "fallback.street", - "must": [ - { - "match_phrase": { - "address_parts.street": "street value" - } - }, - { - "multi_match": { - "query": "neighbourhood value", - "type": "phrase", - "fields": [ - "parent.neighbourhood", - "parent.neighbourhood_a" - ] - } - }, - { - "multi_match": { - "query": "borough value", - "type": "phrase", - "fields": [ - "parent.borough", - "parent.borough_a" - ] - } - }, - { - "multi_match": { - "query": "city value", - "type": "phrase", - "fields": [ - "parent.locality", - "parent.locality_a", - "parent.localadmin", - "parent.localadmin_a" - ] - } - }, - { - "multi_match": { - "query": "county value", - "type": "phrase", - "fields": [ - "parent.county", - "parent.county_a", - "parent.macrocounty", - "parent.macrocounty_a" - ] - } - }, - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a", - "parent.macroregion", - "parent.macroregion_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] - } + { + "bool": { + "_name": "fallback.address", + "must": [ + { + "match_phrase": { + "address_parts.number": "number value" + } + }, + { + "match_phrase": { + "address_parts.street": "street value" + } + }, + { + "multi_match": { + "query": "neighbourhood value", + "type": "phrase", + "fields": [ + "parent.neighbourhood", + "parent.neighbourhood_a" + ] + } + }, + { + "multi_match": { + "query": "borough value", + "type": "phrase", + "fields": [ + "parent.borough", + "parent.borough_a" + ] + } + }, + { + "multi_match": { + "query": "city value", + "type": "phrase", + "fields": [ + "parent.locality", + "parent.locality_a", + "parent.localadmin", + "parent.localadmin_a" + ] + } + }, + { + "multi_match": { + "query": "county value", + "type": "phrase", + "fields": [ + "parent.county", + "parent.county_a", + "parent.macrocounty", + "parent.macrocounty_a" + ] + } + }, + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a", + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "should": [ + { + "match_phrase": { + "address_parts.zip": "postalcode value" + } + } + ], + "filter": { + "term": { + "layer": "address" + } + }, + "boost": 10 } - ], - "should": [ - { - "match_phrase": { - "address_parts.zip": "postalcode value" - } - } - ], - "filter": { - "term": { - "layer": "street" + }, + { + "bool": { + "_name": "fallback.street", + "must": [ + { + "match_phrase": { + "address_parts.street": "street value" + } + }, + { + "multi_match": { + "query": "neighbourhood value", + "type": "phrase", + "fields": [ + "parent.neighbourhood", + "parent.neighbourhood_a" + ] + } + }, + { + "multi_match": { + "query": "borough value", + "type": "phrase", + "fields": [ + "parent.borough", + "parent.borough_a" + ] + } + }, + { + "multi_match": { + "query": "city value", + "type": "phrase", + "fields": [ + "parent.locality", + "parent.locality_a", + "parent.localadmin", + "parent.localadmin_a" + ] + } + }, + { + "multi_match": { + "query": "county value", + "type": "phrase", + "fields": [ + "parent.county", + "parent.county_a", + "parent.macrocounty", + "parent.macrocounty_a" + ] + } + }, + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a", + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "should": [ + { + "match_phrase": { + "address_parts.zip": "postalcode value" + } + } + ], + "filter": { + "term": { + "layer": "street" + } + }, + "boost": 5 } }, - "boost": 5 - } - }, - { - "bool": { - "_name": "fallback.postalcode", - "must": [ - { - "multi_match": { - "query": "postalcode value", - "type": "phrase", - "fields": [ - "parent.postalcode" - ] - } - }, - { - "multi_match": { - "query": "city value", - "type": "phrase", - "fields": [ - "parent.locality", - "parent.locality_a", - "parent.localadmin", - "parent.localadmin_a" - ] - } - }, - { - "multi_match": { - "query": "county value", - "type": "phrase", - "fields": [ - "parent.county", - "parent.county_a", - "parent.macrocounty", - "parent.macrocounty_a" - ] - } - }, - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a", - "parent.macroregion", - "parent.macroregion_a" - ] + { + "bool": { + "_name": "fallback.postalcode", + "must": [ + { + "multi_match": { + "query": "postalcode value", + "type": "phrase", + "fields": [ + "parent.postalcode" + ] + } + }, + { + "multi_match": { + "query": "city value", + "type": "phrase", + "fields": [ + "parent.locality", + "parent.locality_a", + "parent.localadmin", + "parent.localadmin_a" + ] + } + }, + { + "multi_match": { + "query": "county value", + "type": "phrase", + "fields": [ + "parent.county", + "parent.county_a", + "parent.macrocounty", + "parent.macrocounty_a" + ] + } + }, + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a", + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "postalcode" + } } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] - } - } - ], - "filter": { - "term": { - "layer": "postalcode" } - } - } - }, - { - "bool": { - "_name": "fallback.neighbourhood", - "must": [ - { - "multi_match": { - "query": "neighbourhood value", - "type": "phrase", - "fields": [ - "parent.neighbourhood", - "parent.neighbourhood_a" - ] - } - }, - { - "multi_match": { - "query": "borough value", - "type": "phrase", - "fields": [ - "parent.borough", - "parent.borough_a" - ] - } - }, - { - "multi_match": { - "query": "city value", - "type": "phrase", - "fields": [ - "parent.locality", - "parent.locality_a", - "parent.localadmin", - "parent.localadmin_a" - ] - } - }, - { - "multi_match": { - "query": "county value", - "type": "phrase", - "fields": [ - "parent.county", - "parent.county_a", - "parent.macrocounty", - "parent.macrocounty_a" - ] - } - }, - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a", - "parent.macroregion", - "parent.macroregion_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] + }, + { + "bool": { + "_name": "fallback.neighbourhood", + "must": [ + { + "multi_match": { + "query": "neighbourhood value", + "type": "phrase", + "fields": [ + "parent.neighbourhood", + "parent.neighbourhood_a" + ] + } + }, + { + "multi_match": { + "query": "borough value", + "type": "phrase", + "fields": [ + "parent.borough", + "parent.borough_a" + ] + } + }, + { + "multi_match": { + "query": "city value", + "type": "phrase", + "fields": [ + "parent.locality", + "parent.locality_a", + "parent.localadmin", + "parent.localadmin_a" + ] + } + }, + { + "multi_match": { + "query": "county value", + "type": "phrase", + "fields": [ + "parent.county", + "parent.county_a", + "parent.macrocounty", + "parent.macrocounty_a" + ] + } + }, + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a", + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "neighbourhood" + } } } - ], - "filter": { - "term": { - "layer": "neighbourhood" - } - } - } - }, - { - "bool": { - "_name": "fallback.borough", - "must": [ - { - "multi_match": { - "query": "borough value", - "type": "phrase", - "fields": [ - "parent.borough", - "parent.borough_a" - ] - } - }, - { - "multi_match": { - "query": "city value", - "type": "phrase", - "fields": [ - "parent.locality", - "parent.locality_a", - "parent.localadmin", - "parent.localadmin_a" - ] - } - }, - { - "multi_match": { - "query": "county value", - "type": "phrase", - "fields": [ - "parent.county", - "parent.county_a", - "parent.macrocounty", - "parent.macrocounty_a" - ] - } - }, - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a", - "parent.macroregion", - "parent.macroregion_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] + }, + { + "bool": { + "_name": "fallback.borough", + "must": [ + { + "multi_match": { + "query": "borough value", + "type": "phrase", + "fields": [ + "parent.borough", + "parent.borough_a" + ] + } + }, + { + "multi_match": { + "query": "city value", + "type": "phrase", + "fields": [ + "parent.locality", + "parent.locality_a", + "parent.localadmin", + "parent.localadmin_a" + ] + } + }, + { + "multi_match": { + "query": "county value", + "type": "phrase", + "fields": [ + "parent.county", + "parent.county_a", + "parent.macrocounty", + "parent.macrocounty_a" + ] + } + }, + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a", + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "borough" + } } } - ], - "filter": { - "term": { - "layer": "borough" - } - } - } - }, - { - "bool": { - "_name": "fallback.locality", - "must": [ - { - "multi_match": { - "query": "city value", - "type": "phrase", - "fields": [ - "parent.locality", - "parent.locality_a" - ] - } - }, - { - "multi_match": { - "query": "county value", - "type": "phrase", - "fields": [ - "parent.county", - "parent.county_a", - "parent.macrocounty", - "parent.macrocounty_a" - ] - } - }, - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a", - "parent.macroregion", - "parent.macroregion_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] + }, + { + "bool": { + "_name": "fallback.locality", + "must": [ + { + "multi_match": { + "query": "city value", + "type": "phrase", + "fields": [ + "parent.locality", + "parent.locality_a" + ] + } + }, + { + "multi_match": { + "query": "county value", + "type": "phrase", + "fields": [ + "parent.county", + "parent.county_a", + "parent.macrocounty", + "parent.macrocounty_a" + ] + } + }, + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a", + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "locality" + } } } - ], - "filter": { - "term": { - "layer": "locality" - } - } - } - }, - { - "bool": { - "_name": "fallback.localadmin", - "must": [ - { - "multi_match": { - "query": "city value", - "type": "phrase", - "fields": [ - "parent.localadmin", - "parent.localadmin_a" - ] - } - }, - { - "multi_match": { - "query": "county value", - "type": "phrase", - "fields": [ - "parent.county", - "parent.county_a", - "parent.macrocounty", - "parent.macrocounty_a" - ] - } - }, - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a", - "parent.macroregion", - "parent.macroregion_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] + }, + { + "bool": { + "_name": "fallback.localadmin", + "must": [ + { + "multi_match": { + "query": "city value", + "type": "phrase", + "fields": [ + "parent.localadmin", + "parent.localadmin_a" + ] + } + }, + { + "multi_match": { + "query": "county value", + "type": "phrase", + "fields": [ + "parent.county", + "parent.county_a", + "parent.macrocounty", + "parent.macrocounty_a" + ] + } + }, + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a", + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "localadmin" + } } } - ], - "filter": { - "term": { - "layer": "localadmin" - } - } - } - }, - { - "bool": { - "_name": "fallback.county", - "must": [ - { - "multi_match": { - "query": "county value", - "type": "phrase", - "fields": [ - "parent.county", - "parent.county_a" - ] - } - }, - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a", - "parent.macroregion", - "parent.macroregion_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] + }, + { + "bool": { + "_name": "fallback.county", + "must": [ + { + "multi_match": { + "query": "county value", + "type": "phrase", + "fields": [ + "parent.county", + "parent.county_a" + ] + } + }, + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a", + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "county" + } } } - ], - "filter": { - "term": { - "layer": "county" - } - } - } - }, - { - "bool": { - "_name": "fallback.macrocounty", - "must": [ - { - "multi_match": { - "query": "county value", - "type": "phrase", - "fields": [ - "parent.macrocounty", - "parent.macrocounty_a" - ] - } - }, - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a", - "parent.macroregion", - "parent.macroregion_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] + }, + { + "bool": { + "_name": "fallback.macrocounty", + "must": [ + { + "multi_match": { + "query": "county value", + "type": "phrase", + "fields": [ + "parent.macrocounty", + "parent.macrocounty_a" + ] + } + }, + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a", + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "macrocounty" + } } } - ], - "filter": { - "term": { - "layer": "macrocounty" - } - } - } - }, - { - "bool": { - "_name": "fallback.region", - "must": [ - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.region", - "parent.region_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] + }, + { + "bool": { + "_name": "fallback.region", + "must": [ + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.region", + "parent.region_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "region" + } } } - ], - "filter": { - "term": { - "layer": "region" - } - } - } - }, - { - "bool": { - "_name": "fallback.macroregion", - "must": [ - { - "multi_match": { - "query": "state value", - "type": "phrase", - "fields": [ - "parent.macroregion", - "parent.macroregion_a" - ] - } - }, - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a", - "parent.dependency", - "parent.dependency_a" - ] + }, + { + "bool": { + "_name": "fallback.macroregion", + "must": [ + { + "multi_match": { + "query": "state value", + "type": "phrase", + "fields": [ + "parent.macroregion", + "parent.macroregion_a" + ] + } + }, + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a", + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "macroregion" + } } } - ], - "filter": { - "term": { - "layer": "macroregion" - } - } - } - }, - { - "bool": { - "_name": "fallback.dependency", - "must": [ - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.dependency", - "parent.dependency_a" - ] + }, + { + "bool": { + "_name": "fallback.dependency", + "must": [ + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "dependency" + } } } - ], - "filter": { - "term": { - "layer": "dependency" - } - } - } - }, - { - "bool": { - "_name": "fallback.country", - "must": [ - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a" - ] + }, + { + "bool": { + "_name": "fallback.country", + "must": [ + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "country" + } } } - ], - "filter": { - "term": { - "layer": "country" - } } - } + ] + } + }, + "filter": { + "bool": { + "must": [] } - ] + } } }, "max_boost": 20, diff --git a/test/unit/fixture/structured_geocoding/linguistic_bbox.json b/test/unit/fixture/structured_geocoding/linguistic_bbox.json index 33d449d8..2912a10d 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_bbox.json +++ b/test/unit/fixture/structured_geocoding/linguistic_bbox.json @@ -2,8 +2,12 @@ "query": { "function_score": { "query": { - "bool": { - "should": [], + "filtered": { + "query": { + "bool": { + "should": [] + } + }, "filter": { "bool": { "must": [ @@ -58,4 +62,4 @@ ], "size": 10, "track_scores": true -} +} \ No newline at end of file diff --git a/test/unit/fixture/structured_geocoding/linguistic_focus.json b/test/unit/fixture/structured_geocoding/linguistic_focus.json index 78520239..cee04e8e 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_focus.json +++ b/test/unit/fixture/structured_geocoding/linguistic_focus.json @@ -2,8 +2,12 @@ "query": { "function_score": { "query": { - "bool": { - "should": [], + "filtered": { + "query": { + "bool": { + "should": [] + } + }, "filter": { "bool": { "must": [ @@ -61,4 +65,4 @@ ], "size": 10, "track_scores": true -} +} \ No newline at end of file diff --git a/test/unit/fixture/structured_geocoding/linguistic_focus_bbox.json b/test/unit/fixture/structured_geocoding/linguistic_focus_bbox.json index fa5b9f18..8c9e8cef 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_focus_bbox.json +++ b/test/unit/fixture/structured_geocoding/linguistic_focus_bbox.json @@ -2,8 +2,12 @@ "query": { "function_score": { "query": { - "bool": { - "should": [], + "filtered": { + "query": { + "bool": { + "should": [] + } + }, "filter": { "bool": { "must": [ diff --git a/test/unit/fixture/structured_geocoding/linguistic_focus_null_island.json b/test/unit/fixture/structured_geocoding/linguistic_focus_null_island.json index 2c58ab75..59fd11bb 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_focus_null_island.json +++ b/test/unit/fixture/structured_geocoding/linguistic_focus_null_island.json @@ -2,8 +2,12 @@ "query": { "function_score": { "query": { - "bool": { - "should": [], + "filtered": { + "query": { + "bool": { + "should": [] + } + }, "filter": { "bool": { "must": [ @@ -61,4 +65,4 @@ ], "size": 10, "track_scores": true -} +} \ No newline at end of file diff --git a/test/unit/fixture/structured_geocoding/linguistic_only.json b/test/unit/fixture/structured_geocoding/linguistic_only.json index 94080ea7..17a54486 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_only.json +++ b/test/unit/fixture/structured_geocoding/linguistic_only.json @@ -2,8 +2,12 @@ "query": { "function_score": { "query": { - "bool": { - "should": [], + "filtered": { + "query": { + "bool": { + "should": [] + } + }, "filter": { "bool": { "must": [ @@ -47,4 +51,4 @@ ], "size": 10, "track_scores": true -} +} \ No newline at end of file diff --git a/test/unit/fixture/structured_geocoding/linguistic_viewport.json b/test/unit/fixture/structured_geocoding/linguistic_viewport.json index 94080ea7..17a54486 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_viewport.json +++ b/test/unit/fixture/structured_geocoding/linguistic_viewport.json @@ -2,8 +2,12 @@ "query": { "function_score": { "query": { - "bool": { - "should": [], + "filtered": { + "query": { + "bool": { + "should": [] + } + }, "filter": { "bool": { "must": [ @@ -47,4 +51,4 @@ ], "size": 10, "track_scores": true -} +} \ No newline at end of file diff --git a/test/unit/fixture/structured_geocoding/linguistic_viewport_min_diagonal.json b/test/unit/fixture/structured_geocoding/linguistic_viewport_min_diagonal.json index 94080ea7..17a54486 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_viewport_min_diagonal.json +++ b/test/unit/fixture/structured_geocoding/linguistic_viewport_min_diagonal.json @@ -2,8 +2,12 @@ "query": { "function_score": { "query": { - "bool": { - "should": [], + "filtered": { + "query": { + "bool": { + "should": [] + } + }, "filter": { "bool": { "must": [ @@ -47,4 +51,4 @@ ], "size": 10, "track_scores": true -} +} \ No newline at end of file diff --git a/test/unit/fixture/structured_geocoding/postalcode_only.js b/test/unit/fixture/structured_geocoding/postalcode_only.js index addac692..7dafbaa0 100644 --- a/test/unit/fixture/structured_geocoding/postalcode_only.js +++ b/test/unit/fixture/structured_geocoding/postalcode_only.js @@ -2,30 +2,39 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.postalcode', - 'must': [ - { - 'multi_match': { - 'query': 'postalcode value', - 'type': 'phrase', - 'fields': [ - 'parent.postalcode' - ] + 'filtered': { + 'query': { + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.postalcode', + 'must': [ + { + 'multi_match': { + 'query': 'postalcode value', + 'type': 'phrase', + 'fields': [ + 'parent.postalcode' + ] + } + } + ], + 'filter': { + 'term': { + 'layer': 'postalcode' + } } } - ], - 'filter': { - 'term': { - 'layer': 'postalcode' - } } - } + ] + } + }, + 'filter': { + 'bool': { + 'must': [] } - ] + } } }, 'max_boost': 20, diff --git a/test/unit/fixture/structured_geocoding/with_source_filtering.json b/test/unit/fixture/structured_geocoding/with_source_filtering.json index 67357881..659d5eb4 100644 --- a/test/unit/fixture/structured_geocoding/with_source_filtering.json +++ b/test/unit/fixture/structured_geocoding/with_source_filtering.json @@ -2,9 +2,12 @@ "query": { "function_score": { "query": { - "bool": { - "should": [ - ], + "filtered": { + "query": { + "bool": { + "should": [] + } + }, "filter": { "bool": { "must": [ @@ -48,4 +51,4 @@ ], "size": 20, "track_scores": true -} +} \ No newline at end of file