From e1eeb25776123cf06d7b7fa5f0fe4a44fe88575e Mon Sep 17 00:00:00 2001 From: Diana Shkolnikov Date: Thu, 6 Apr 2017 18:41:16 -0400 Subject: [PATCH 1/9] fix: geonames ids should not be misrepresented in hiearchy --- middleware/normalizeParentIds.js | 17 +++- test/unit/middleware/normalizeParentIds.js | 106 +++++++++++++++++++++ 2 files changed, 120 insertions(+), 3 deletions(-) diff --git a/middleware/normalizeParentIds.js b/middleware/normalizeParentIds.js index ae22a3c6..60c1fa04 100644 --- a/middleware/normalizeParentIds.js +++ b/middleware/normalizeParentIds.js @@ -15,6 +15,8 @@ function setup() { return next(); } + console.log(JSON.stringify(res.data, null, 2)); + res.data = res.data.map(normalizeParentIds); next(); @@ -32,7 +34,16 @@ function normalizeParentIds(place) { if (place) { placeTypes.forEach(function (placeType) { if (place[placeType] && place[placeType].length > 0 && place[placeType][0]) { - place[placeType + '_gid'] = [ makeNewId(placeType, place[placeType + '_gid']) ]; + var source = 'whosonfirst'; + + // looking forward to the day we can remove all geonames specific hacks, but until then... + // geonames sometimes has its own ids in the parent hierarchy, so it's dangerous to assume that + // it's always WOF ids and hardcode to that + if (place.source === 'geonames' && place.source_id === place[placeType + '_gid'][0]) { + source = place.source; + } + + place[placeType + '_gid'] = [ makeNewId(source, placeType, place[placeType + '_gid']) ]; } }); } @@ -48,12 +59,12 @@ function normalizeParentIds(place) { * @param {number} id * @return {string} */ -function makeNewId(placeType, id) { +function makeNewId(source, placeType, id) { if (!id) { return; } - var doc = new Document('whosonfirst', placeType, id); + var doc = new Document(source, placeType, id); return doc.getGid(); } diff --git a/test/unit/middleware/normalizeParentIds.js b/test/unit/middleware/normalizeParentIds.js index 472df0e3..8388f67d 100644 --- a/test/unit/middleware/normalizeParentIds.js +++ b/test/unit/middleware/normalizeParentIds.js @@ -77,6 +77,112 @@ module.exports.tests.interface = function(test, common) { }); }); + + test('Geonames ids do not override parent hierarchy with WOF equivalents', function(t) { + + var input = { + data: [{ + 'parent': { + 'country_id': [ '85633793' ], + 'country': [ 'United States' ], + 'country_a': [ 'USA' ], + 'region_id': [ '85688579' ], + 'region': [ 'Mississippi' ], + 'region_a': [ 'MS' ] + }, + 'source': 'geonames', + 'source_id': '4436296', + 'layer': 'region', + 'country': [ 'United States' ], + 'country_a': [ 'USA' ], + 'country_gid': [ '85633793' ], + 'region': [ 'Mississippi' ], + 'region_a': [ 'MS' ], + 'region_gid': [ '85688579' ] + }] + }; + + var expected = { + data: [{ + 'parent': { + 'country_id': [ '85633793' ], + 'country': [ 'United States' ], + 'country_a': [ 'USA' ], + 'region_id': [ '85688579' ], + 'region': [ 'Mississippi' ], + 'region_a': [ 'MS' ] + }, + 'layer': 'region', + 'source': 'geonames', + 'source_id': '4436296', + 'country': ['United States'], + 'country_gid': ['whosonfirst:country:85633793'], + 'country_a': ['USA'], + 'region': ['Mississippi'], + 'region_gid': ['whosonfirst:region:85688579'], + 'region_a': ['MS'] + }] + }; + + normalizer({}, input, function () { + t.deepEqual(input, expected); + t.end(); + }); + + }); + + test('Geonames ids do not override parent hierarchy with WOF equivalents', function(t) { + + var input = { + data: [{ + 'parent': { + 'country_id': [ '85633793' ], + 'country': [ 'United States' ], + 'country_a': ['USA'], + 'region_id': [ '4436296' ], + 'region': [ 'Mississippi' ], + 'region_a': [ 'MS' ] + }, + 'source': 'geonames', + 'source_id': '4436296', + 'layer': 'region', + 'country': [ 'United States' ], + 'country_a': [ 'USA' ], + 'country_gid': ['85633793'], + 'region': [ 'Mississippi' ], + 'region_a': [ 'MS' ], + 'region_gid': [ '4436296' ] + }] + }; + + var expected = { + data: [{ + 'parent': { + 'country_id': [ '85633793' ], + 'country': [ 'United States' ], + 'country_a': [ 'USA' ], + 'region_id': [ '4436296' ], + 'region': [ 'Mississippi' ], + 'region_a': [ 'MS' ] + }, + 'layer': 'region', + 'source': 'geonames', + 'source_id': '4436296', + 'country': ['United States'], + 'country_gid': ['whosonfirst:country:85633793'], + 'country_a': ['USA'], + 'region': ['Mississippi'], + 'region_gid': ['geonames:region:4436296'], + 'region_a': ['MS'] + }] + }; + + normalizer({}, input, function () { + t.deepEqual(input, expected); + t.end(); + }); + + }); }; module.exports.all = function (tape, common) { From 798363da1e200323cd22e41648996e12841002a0 Mon Sep 17 00:00:00 2001 From: Diana Shkolnikov Date: Fri, 7 Apr 2017 10:57:43 -0400 Subject: [PATCH 2/9] remove unwanted log statement --- middleware/normalizeParentIds.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/middleware/normalizeParentIds.js b/middleware/normalizeParentIds.js index 60c1fa04..22fc43f8 100644 --- a/middleware/normalizeParentIds.js +++ b/middleware/normalizeParentIds.js @@ -15,8 +15,6 @@ function setup() { return next(); } - console.log(JSON.stringify(res.data, null, 2)); - res.data = res.data.map(normalizeParentIds); next(); From 864ab53a967cab88f21338a6c2ae122a71f208c5 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 12 Apr 2017 16:03:39 +0000 Subject: [PATCH 3/9] fix(package): update pelias-query to version 8.16.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e9d354cc..958d39f5 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.15.0", + "pelias-query": "8.16.0", "pelias-text-analyzer": "1.7.3", "predicates": "^1.0.1", "retry": "^0.10.1", From 81b52fafafd0cce78a4c9ad859a16c4755d58dfd Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 13 Apr 2017 15:45:49 -0400 Subject: [PATCH 4/9] Use bool instead of filtered queries in fixtures This is needed for Elasticsearch 5 support as part of https://github.com/pelias/pelias/issues/461 --- 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 +- 23 files changed, 1832 insertions(+), 1943 deletions(-) diff --git a/test/unit/fixture/search_boundary_country.js b/test/unit/fixture/search_boundary_country.js index ee6427a0..e03a2b8b 100644 --- a/test/unit/fixture/search_boundary_country.js +++ b/test/unit/fixture/search_boundary_country.js @@ -2,32 +2,28 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' } } + ], + '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 3835cadb..86c477f0 100644 --- a/test/unit/fixture/search_fallback.js +++ b/test/unit/fixture/search_fallback.js @@ -2,837 +2,828 @@ module.exports = { 'query': { 'function_score': { 'query': { - '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' - } + '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' } - }, - { - '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' - } + } + } + }, + { + '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.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' - } + ], + 'should': [ + { + 'match_phrase': { + 'address_parts.zip': 'postalcode value' } } - }, - { - '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' - } + ], + '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' + ] } + }, + { + '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' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'neighbourhood' - } + } + } + }, + { + '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.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' - } + ], + 'should': [ + { + 'match_phrase': { + 'address_parts.zip': 'postalcode value' } } - }, - { - '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': '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' + ] } + }, + { + '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.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.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.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': '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' + ] } + }, + { + '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' - ] - } - }, - { - '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.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' } - }, - { - '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' - } + } + } + }, + { + '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' } - }, - { - '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' - } + } + } + }, + { + '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.dependency', - 'must': [ - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.dependency', - 'parent.dependency_a' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'dependency' - } + ], + '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.country', - 'must': [ - { - 'multi_match': { - 'query': 'country value', - 'type': 'phrase', - 'fields': [ - 'parent.country', - 'parent.country_a' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'country' - } + ], + 'filter': { + 'term': { + 'layer': 'dependency' + } + } + } + }, + { + 'bool': { + '_name': 'fallback.country', + 'must': [ + { + 'multi_match': { + 'query': 'country value', + 'type': 'phrase', + 'fields': [ + 'parent.country', + 'parent.country_a' + ] } } + ], + '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 4519e166..c2c296e7 100644 --- a/test/unit/fixture/search_fallback_postalcode_only.js +++ b/test/unit/fixture/search_fallback_postalcode_only.js @@ -2,39 +2,30 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.postalcode', - 'must': [ - { - 'multi_match': { - 'query': '90210', - 'type': 'phrase', - 'fields': [ - 'parent.postalcode' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'postalcode' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.postalcode', + 'must': [ + { + 'multi_match': { + 'query': '90210', + 'type': 'phrase', + 'fields': [ + 'parent.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 e74f6c79..9e02cbc4 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -2,32 +2,28 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' } } + ], + '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 a63400b3..218dbbb1 100644 --- a/test/unit/fixture/search_linguistic_focus.js +++ b/test/unit/fixture/search_linguistic_focus.js @@ -2,32 +2,28 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' } } + ], + '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 7f6c8528..88ee6d68 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -2,32 +2,28 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' } } + ], + '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 da12154a..8603a1db 100644 --- a/test/unit/fixture/search_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_linguistic_focus_null_island.js @@ -2,32 +2,28 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' } } + ], + '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 0117e03b..c99d4eff 100644 --- a/test/unit/fixture/search_linguistic_only.js +++ b/test/unit/fixture/search_linguistic_only.js @@ -2,32 +2,28 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' } } + ], + '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 0117e03b..c99d4eff 100644 --- a/test/unit/fixture/search_linguistic_viewport.js +++ b/test/unit/fixture/search_linguistic_viewport.js @@ -2,32 +2,28 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' } } + ], + '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 0117e03b..c99d4eff 100644 --- a/test/unit/fixture/search_linguistic_viewport_min_diagonal.js +++ b/test/unit/fixture/search_linguistic_viewport_min_diagonal.js @@ -2,32 +2,28 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' } } + ], + '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 05f9ec4e..0ea7fc93 100644 --- a/test/unit/fixture/search_with_category_filtering.js +++ b/test/unit/fixture/search_with_category_filtering.js @@ -2,32 +2,28 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' } } + ], + '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 0e9010c2..efccbe52 100644 --- a/test/unit/fixture/search_with_source_filtering.js +++ b/test/unit/fixture/search_with_source_filtering.js @@ -2,32 +2,28 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.street', - 'boost': 5, - 'must': [ - { - 'match_phrase': { - 'address_parts.street': 'street value' - } - } - ], - 'should': [], - 'filter': { - 'term': { - 'layer': 'street' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.street', + 'boost': 5, + 'must': [ + { + 'match_phrase': { + 'address_parts.street': 'street value' } } + ], + '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 182da5a9..9a73c22d 100644 --- a/test/unit/fixture/structured_geocoding/boundary_country.json +++ b/test/unit/fixture/structured_geocoding/boundary_country.json @@ -2,12 +2,8 @@ "query": { "function_score": { "query": { - "filtered": { - "query": { - "bool": { - "should": [] - } - }, + "bool": { + "should": [], "filter": { "bool": { "must": [ @@ -59,4 +55,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 58d0ce8c..92c2674d 100644 --- a/test/unit/fixture/structured_geocoding/fallback.json +++ b/test/unit/fixture/structured_geocoding/fallback.json @@ -2,838 +2,829 @@ "query": { "function_score": { "query": { - "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" - } + "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" + ] } } - }, - { - "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 + ], + "filter": { + "term": { + "layer": "venue" } - }, - { - "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 + } + } + }, + { + "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" + ] + } } - }, - { - "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" - } + ], + "should": [ + { + "match_phrase": { + "address_parts.zip": "postalcode value" } } + ], + "filter": { + "term": { + "layer": "address" + } }, - { - "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" - } + "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.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" - } + ], + "should": [ + { + "match_phrase": { + "address_parts.zip": "postalcode value" } } + ], + "filter": { + "term": { + "layer": "street" + } }, - { - "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" - } + "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" + ] + } + }, + { + "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": "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.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": "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.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": "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.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": "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.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": "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.dependency", - "must": [ - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.dependency", - "parent.dependency_a" - ] - } - } - ], - "filter": { - "term": { - "layer": "dependency" - } + ], + "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.country", - "must": [ - { - "multi_match": { - "query": "country value", - "type": "phrase", - "fields": [ - "parent.country", - "parent.country_a" - ] - } - } - ], - "filter": { - "term": { - "layer": "country" - } + ], + "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" + ] } } + ], + "filter": { + "term": { + "layer": "region" + } } - ] - } - }, - "filter": { - "bool": { - "must": [] + } + }, + { + "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" + } + } + } + }, + { + "bool": { + "_name": "fallback.dependency", + "must": [ + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.dependency", + "parent.dependency_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "dependency" + } + } + } + }, + { + "bool": { + "_name": "fallback.country", + "must": [ + { + "multi_match": { + "query": "country value", + "type": "phrase", + "fields": [ + "parent.country", + "parent.country_a" + ] + } + } + ], + "filter": { + "term": { + "layer": "country" + } + } + } } - } + ] } }, "max_boost": 20, diff --git a/test/unit/fixture/structured_geocoding/linguistic_bbox.json b/test/unit/fixture/structured_geocoding/linguistic_bbox.json index 2912a10d..33d449d8 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_bbox.json +++ b/test/unit/fixture/structured_geocoding/linguistic_bbox.json @@ -2,12 +2,8 @@ "query": { "function_score": { "query": { - "filtered": { - "query": { - "bool": { - "should": [] - } - }, + "bool": { + "should": [], "filter": { "bool": { "must": [ @@ -62,4 +58,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 cee04e8e..78520239 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_focus.json +++ b/test/unit/fixture/structured_geocoding/linguistic_focus.json @@ -2,12 +2,8 @@ "query": { "function_score": { "query": { - "filtered": { - "query": { - "bool": { - "should": [] - } - }, + "bool": { + "should": [], "filter": { "bool": { "must": [ @@ -65,4 +61,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 8c9e8cef..fa5b9f18 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_focus_bbox.json +++ b/test/unit/fixture/structured_geocoding/linguistic_focus_bbox.json @@ -2,12 +2,8 @@ "query": { "function_score": { "query": { - "filtered": { - "query": { - "bool": { - "should": [] - } - }, + "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 59fd11bb..2c58ab75 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_focus_null_island.json +++ b/test/unit/fixture/structured_geocoding/linguistic_focus_null_island.json @@ -2,12 +2,8 @@ "query": { "function_score": { "query": { - "filtered": { - "query": { - "bool": { - "should": [] - } - }, + "bool": { + "should": [], "filter": { "bool": { "must": [ @@ -65,4 +61,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 17a54486..94080ea7 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_only.json +++ b/test/unit/fixture/structured_geocoding/linguistic_only.json @@ -2,12 +2,8 @@ "query": { "function_score": { "query": { - "filtered": { - "query": { - "bool": { - "should": [] - } - }, + "bool": { + "should": [], "filter": { "bool": { "must": [ @@ -51,4 +47,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 17a54486..94080ea7 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_viewport.json +++ b/test/unit/fixture/structured_geocoding/linguistic_viewport.json @@ -2,12 +2,8 @@ "query": { "function_score": { "query": { - "filtered": { - "query": { - "bool": { - "should": [] - } - }, + "bool": { + "should": [], "filter": { "bool": { "must": [ @@ -51,4 +47,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 17a54486..94080ea7 100644 --- a/test/unit/fixture/structured_geocoding/linguistic_viewport_min_diagonal.json +++ b/test/unit/fixture/structured_geocoding/linguistic_viewport_min_diagonal.json @@ -2,12 +2,8 @@ "query": { "function_score": { "query": { - "filtered": { - "query": { - "bool": { - "should": [] - } - }, + "bool": { + "should": [], "filter": { "bool": { "must": [ @@ -51,4 +47,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 7dafbaa0..addac692 100644 --- a/test/unit/fixture/structured_geocoding/postalcode_only.js +++ b/test/unit/fixture/structured_geocoding/postalcode_only.js @@ -2,39 +2,30 @@ module.exports = { 'query': { 'function_score': { 'query': { - 'filtered': { - 'query': { - 'bool': { - 'should': [ - { - 'bool': { - '_name': 'fallback.postalcode', - 'must': [ - { - 'multi_match': { - 'query': 'postalcode value', - 'type': 'phrase', - 'fields': [ - 'parent.postalcode' - ] - } - } - ], - 'filter': { - 'term': { - 'layer': 'postalcode' - } + 'bool': { + 'should': [ + { + 'bool': { + '_name': 'fallback.postalcode', + 'must': [ + { + 'multi_match': { + 'query': 'postalcode value', + 'type': 'phrase', + 'fields': [ + 'parent.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 659d5eb4..67357881 100644 --- a/test/unit/fixture/structured_geocoding/with_source_filtering.json +++ b/test/unit/fixture/structured_geocoding/with_source_filtering.json @@ -2,12 +2,9 @@ "query": { "function_score": { "query": { - "filtered": { - "query": { - "bool": { - "should": [] - } - }, + "bool": { + "should": [ + ], "filter": { "bool": { "must": [ @@ -51,4 +48,4 @@ ], "size": 20, "track_scores": true -} \ No newline at end of file +} From c585b00a9b26e810933af1a915056e2bbbb1368d Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 13 Apr 2017 15:54:13 -0400 Subject: [PATCH 5/9] Remove unused reverse fixture This must have been missed when we removed boundary.circle a long time ago. --- test/unit/fixture/reverse_boundary_circle.js | 43 -------------------- 1 file changed, 43 deletions(-) delete mode 100644 test/unit/fixture/reverse_boundary_circle.js diff --git a/test/unit/fixture/reverse_boundary_circle.js b/test/unit/fixture/reverse_boundary_circle.js deleted file mode 100644 index 4fc728a2..00000000 --- a/test/unit/fixture/reverse_boundary_circle.js +++ /dev/null @@ -1,43 +0,0 @@ -var vs = require('../../../query/reverse_defaults'); - -module.exports = { - 'query': { - 'filtered': { - 'query': { - 'bool': {} - }, - 'filter': { - 'bool': { - 'must': [ - { - 'geo_distance': { - 'distance': vs.distance, - 'distance_type': 'plane', - 'optimize_bbox': 'indexed', - 'center_point': { - 'lat': 29.49136, - 'lon': -82.50622 - } - } - } - ] - } - } - } - }, - 'sort': [ - '_score', - { - '_geo_distance': { - 'center_point': { - 'lat': 29.49136, - 'lon': -82.50622 - }, - 'order': 'asc', - 'distance_type': 'plane' - } - } - ], - 'size': vs.size, - 'track_scores': true -}; From da314495d791207f9190dc8974bd36cf7278505d Mon Sep 17 00:00:00 2001 From: Diana Shkolnikov Date: Tue, 18 Apr 2017 13:28:35 -0400 Subject: [PATCH 6/9] disable updates in npm-check --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 958d39f5..68d37222 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "difflet": "^1.0.1", "istanbul": "^0.4.2", "jshint": "^2.5.6", - "npm-check": "^5.4.0", + "npm-check": "git://github.com/orangejulius/npm-check.git#disable-update-check", "nsp": "^2.2.0", "precommit-hook": "^3.0.0", "proxyquire": "^1.7.10", From a7867579dee0d64919f3378fe8739cba9a9520a2 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Wed, 19 Apr 2017 10:55:26 -0400 Subject: [PATCH 7/9] pass dnt to pip service and sanitize error messages --- service/pointinpolygon.js | 58 ++++++++-- test/unit/service/pointinpolygon.js | 174 ++++++++++++++++++++++++++-- 2 files changed, 214 insertions(+), 18 deletions(-) diff --git a/service/pointinpolygon.js b/service/pointinpolygon.js index 21b6fdcf..1e58dfa3 100644 --- a/service/pointinpolygon.js +++ b/service/pointinpolygon.js @@ -2,14 +2,51 @@ const logger = require( 'pelias-logger' ).get( 'pointinpolygon' ); const request = require('request'); const _ = require('lodash'); +function sanitizeUrl(requestUrl) { + return requestUrl.replace(/^(.+)\/.+\/.+$/, (match, base) => { + return `${base}/[removed]/[removed]`; + }); +} + +function parseErrorMessage(requestUrl, body, do_not_track) { + if (do_not_track) { + return `${sanitizeUrl(requestUrl)} returned status 200 but with non-JSON response: ${body}`; + } + + return `${requestUrl} returned status 200 but with non-JSON response: ${body}`; + +} + +function serviceErrorMessage(requestUrl, statusCode, body, do_not_track) { + if (do_not_track) { + return `${sanitizeUrl(requestUrl)} returned status ${statusCode}: ${body}`; + + } else { + return `${requestUrl} returned status ${statusCode}: ${body}`; + + } + +} + module.exports = (url) => { if (!_.isEmpty(url)) { logger.info(`using point-in-polygon service at ${url}`); - return function pointinpolygon( centroid, callback ) { + return function pointinpolygon( centroid, do_not_track, callback ) { const requestUrl = `${url}/${centroid.lon}/${centroid.lat}`; - request.get(requestUrl, (err, response, body) => { + const options = { + method: 'GET', + url: requestUrl + }; + + if (do_not_track) { + options.headers = { + dnt: '1' + }; + } + + request(options, (err, response, body) => { if (err) { logger.error(JSON.stringify(err)); callback(err); @@ -20,13 +57,17 @@ module.exports = (url) => { callback(err, parsed); } catch (err) { - logger.error(`${requestUrl}: could not parse response body: ${body}`); - callback(`${requestUrl} returned status 200 but with non-JSON response: ${body}`); + const parseMsg = parseErrorMessage(requestUrl, body, do_not_track); + + logger.error(parseMsg); + callback(parseMsg); } } else { - logger.error(`${requestUrl} returned status ${response.statusCode}: ${body}`); - callback(`${requestUrl} returned status ${response.statusCode}: ${body}`); + const errorMsg = serviceErrorMessage(requestUrl, response.statusCode, body, do_not_track); + + logger.error(errorMsg); + callback(errorMsg); } }); @@ -35,8 +76,9 @@ module.exports = (url) => { } else { logger.warn('point-in-polygon service disabled'); - return (centroid, callback) => { - callback(`point-in-polygon service disabled, unable to resolve ${JSON.stringify(centroid)}`); + return (centroid, do_not_track, callback) => { + callback(`point-in-polygon service disabled, unable to resolve ` + + (do_not_track ? 'centroid' : JSON.stringify(centroid))); }; } diff --git a/test/unit/service/pointinpolygon.js b/test/unit/service/pointinpolygon.js index ac08b3f7..7280aa7f 100644 --- a/test/unit/service/pointinpolygon.js +++ b/test/unit/service/pointinpolygon.js @@ -25,7 +25,7 @@ module.exports.tests.do_nothing_service = (test, common) => { 'pelias-logger': logger })(); - service({ lat: 12.121212, lon: 21.212121 }, (err) => { + service({ lat: 12.121212, lon: 21.212121 }, false, (err) => { t.deepEquals(logger.getWarnMessages(), [ 'point-in-polygon service disabled' ]); @@ -35,6 +35,23 @@ module.exports.tests.do_nothing_service = (test, common) => { }); + test('service unavailable message should not output centroid when do_not_track is true', (t) => { + const logger = require('pelias-mock-logger')(); + + const service = proxyquire('../../../service/pointinpolygon', { + 'pelias-logger': logger + })(); + + service({ lat: 12.121212, lon: 21.212121 }, true, (err) => { + t.deepEquals(logger.getWarnMessages(), [ + 'point-in-polygon service disabled' + ]); + t.equals(err, 'point-in-polygon service disabled, unable to resolve centroid'); + t.end(); + }); + + }); + }; module.exports.tests.success = (test, common) => { @@ -56,13 +73,81 @@ module.exports.tests.success = (test, common) => { 'pelias-logger': logger })(`http://localhost:${port}`); - service({ lat: 12.121212, lon: 21.212121}, (err, results) => { + service({ lat: 12.121212, lon: 21.212121}, false, (err, results) => { + t.notOk(err); + t.deepEquals(results, { field: 'value' }); + + t.ok(logger.isInfoMessage(`using point-in-polygon service at http://localhost:${port}`)); + t.notOk(logger.hasErrorMessages()); + + t.end(); + + server.close(); + + }); + + }); + + test('do_not_track=true should pass DNT header', (t) => { + const pipServer = require('express')(); + pipServer.get('/:lon/:lat', (req, res, next) => { + t.ok(req.headers.hasOwnProperty('dnt')); + t.equals(req.params.lat, '12.121212'); + t.equals(req.params.lon, '21.212121'); + + res.send('{ "field": "value" }'); + }); + + const server = pipServer.listen(); + const port = server.address().port; + + const logger = require('pelias-mock-logger')(); + + const service = proxyquire('../../../service/pointinpolygon', { + 'pelias-logger': logger + })(`http://localhost:${port}`); + + service({ lat: 12.121212, lon: 21.212121}, true, (err, results) => { + t.notOk(err); + t.deepEquals(results, { field: 'value' }); + + t.ok(logger.isInfoMessage(`using point-in-polygon service at http://localhost:${port}`)); + t.notOk(logger.hasErrorMessages()); + + t.end(); + + server.close(); + + }); + + }); + + test('do_not_track=false should not pass DNT header', (t) => { + const pipServer = require('express')(); + pipServer.get('/:lon/:lat', (req, res, next) => { + t.notOk(req.headers.hasOwnProperty('dnt')); + t.equals(req.params.lat, '12.121212'); + t.equals(req.params.lon, '21.212121'); + + res.send('{ "field": "value" }'); + }); + + const server = pipServer.listen(); + const port = server.address().port; + + const logger = require('pelias-mock-logger')(); + + const service = proxyquire('../../../service/pointinpolygon', { + 'pelias-logger': logger + })(`http://localhost:${port}`); + + service({ lat: 12.121212, lon: 21.212121}, false, (err, results) => { t.notOk(err); t.deepEquals(results, { field: 'value' }); t.ok(logger.isInfoMessage(`using point-in-polygon service at http://localhost:${port}`)); t.notOk(logger.hasErrorMessages()); - + t.end(); server.close(); @@ -92,10 +177,46 @@ module.exports.tests.failure = (test, common) => { 'pelias-logger': logger })(`http://localhost:${port}`); - service({ lat: 12.121212, lon: 21.212121}, (err, results) => { - t.equals(err, `http://localhost:${port}/21.212121/12.121212 returned status 200 but with non-JSON response: this is not JSON`); + const expectedErrorMsg = `http://localhost:${port}/21.212121/12.121212 returned ` + + `status 200 but with non-JSON response: this is not JSON`; + + service({ lat: 12.121212, lon: 21.212121}, false, (err, results) => { + t.equals(err, expectedErrorMsg); t.notOk(results); - t.ok(logger.isErrorMessage(`http://localhost:${port}/21.212121/12.121212: could not parse response body: this is not JSON`)); + t.ok(logger.isErrorMessage(expectedErrorMsg)); + t.end(); + + server.close(); + + }); + + }); + + test('server returning 200 & non-JSON body should log sanitized error and return no results when do_not_track', (t) => { + const pipServer = require('express')(); + pipServer.get('/:lon/:lat', (req, res, next) => { + t.equals(req.params.lat, '12.121212'); + t.equals(req.params.lon, '21.212121'); + + res.send('this is not JSON'); + }); + + const server = pipServer.listen(); + const port = server.address().port; + + const logger = require('pelias-mock-logger')(); + + const service = proxyquire('../../../service/pointinpolygon', { + 'pelias-logger': logger + })(`http://localhost:${port}`); + + const expectedErrorMsg = `http://localhost:${port}/[removed]/[removed] returned ` + + `status 200 but with non-JSON response: this is not JSON`; + + service({ lat: 12.121212, lon: 21.212121}, true, (err, results) => { + t.equals(err, expectedErrorMsg); + t.notOk(results); + t.ok(logger.isErrorMessage(expectedErrorMsg)); t.end(); server.close(); @@ -117,7 +238,7 @@ module.exports.tests.failure = (test, common) => { 'pelias-logger': logger })(`http://localhost:${port}`); - service({ lat: 12.121212, lon: 21.212121}, (err, results) => { + service({ lat: 12.121212, lon: 21.212121}, false, (err, results) => { t.equals(err.code, 'ECONNREFUSED'); t.notOk(results); t.ok(logger.isErrorMessage(/ECONNREFUSED/), 'there should be a connection refused error message'); @@ -144,10 +265,43 @@ module.exports.tests.failure = (test, common) => { 'pelias-logger': logger })(`http://localhost:${port}`); - service({ lat: 12.121212, lon: 21.212121}, (err, results) => { - t.equals(err, `http://localhost:${port}/21.212121/12.121212 returned status 400: a bad request was made`); + const expectedErrorMsg = `http://localhost:${port}/21.212121/12.121212 returned ` + + `status 400: a bad request was made`; + + service({ lat: 12.121212, lon: 21.212121}, false, (err, results) => { + t.equals(err, expectedErrorMsg); + t.notOk(results); + t.ok(logger.isErrorMessage(expectedErrorMsg)); + t.end(); + + server.close(); + + }); + + }); + + test('non-OK status should log sanitized error and return no results when do_not_track=true', (t) => { + const pipServer = require('express')(); + pipServer.get('/:lat/:lon', (req, res, next) => { + res.status(400).send('a bad request was made'); + }); + + const server = pipServer.listen(); + const port = server.address().port; + + const logger = require('pelias-mock-logger')(); + + const service = proxyquire('../../../service/pointinpolygon', { + 'pelias-logger': logger + })(`http://localhost:${port}`); + + const expectedErrorMsg = `http://localhost:${port}/[removed]/[removed] returned ` + + `status 400: a bad request was made`; + + service({ lat: 12.121212, lon: 21.212121}, true, (err, results) => { + t.equals(err, expectedErrorMsg); t.notOk(results); - t.ok(logger.isErrorMessage(`http://localhost:${port}/21.212121/12.121212 returned status 400: a bad request was made`)); + t.ok(logger.isErrorMessage(expectedErrorMsg)); t.end(); server.close(); From d80d34cfd95d1ce8654164c3923855d087b1ac29 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Wed, 19 Apr 2017 16:59:29 -0400 Subject: [PATCH 8/9] actually pass do-not-track to service --- controller/coarse_reverse.js | 3 +- test/unit/controller/coarse_reverse.js | 60 ++++++++++++++++++++------ 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/controller/coarse_reverse.js b/controller/coarse_reverse.js index dc48d6db..d080298c 100644 --- a/controller/coarse_reverse.js +++ b/controller/coarse_reverse.js @@ -1,6 +1,7 @@ const logger = require('pelias-logger').get('coarse_reverse'); const _ = require('lodash'); const Document = require('pelias-model').Document; +const isDNT = require('../helper/logging').isDNT; const granularities = [ 'neighbourhood', @@ -88,7 +89,7 @@ function setup(service, should_execute) { lon: req.clean['point.lon'] }; - service(centroid, (err, results) => { + service(centroid, isDNT(req), (err, results) => { // if there's an error, log it and bail if (err) { logger.error(err); diff --git a/test/unit/controller/coarse_reverse.js b/test/unit/controller/coarse_reverse.js index d8071e62..2389cc43 100644 --- a/test/unit/controller/coarse_reverse.js +++ b/test/unit/controller/coarse_reverse.js @@ -46,7 +46,8 @@ module.exports.tests.early_exit_conditions = (test, common) => { module.exports.tests.error_conditions = (test, common) => { test('service error should log and call next', (t) => { - const service = (point, callback) => { + const service = (point, do_not_track, callback) => { + t.equals(do_not_track, 'do_not_track value'); callback('this is an error'); }; @@ -54,7 +55,12 @@ module.exports.tests.error_conditions = (test, common) => { const should_execute = () => { return true; }; const controller = proxyquire('../../../controller/coarse_reverse', { - 'pelias-logger': logger + 'pelias-logger': logger, + '../helper/logging': { + isDNT: () => { + return 'do_not_track value'; + } + } })(service, should_execute); const req = { @@ -86,7 +92,8 @@ module.exports.tests.error_conditions = (test, common) => { module.exports.tests.success_conditions = (test, common) => { test('service returning results should use first entry for each layer', (t) => { - const service = (point, callback) => { + const service = (point, do_not_track, callback) => { + t.equals(do_not_track, 'do_not_track value'); const results = { neighbourhood: [ { @@ -146,7 +153,12 @@ module.exports.tests.success_conditions = (test, common) => { const should_execute = () => { return true; }; const controller = proxyquire('../../../controller/coarse_reverse', { - 'pelias-logger': logger + 'pelias-logger': logger, + '../helper/logging': { + isDNT: () => { + return 'do_not_track value'; + } + } })(service, should_execute); const req = { @@ -235,7 +247,8 @@ module.exports.tests.success_conditions = (test, common) => { }); test('layers missing from results should be ignored', (t) => { - const service = (point, callback) => { + const service = (point, do_not_track, callback) => { + t.equals(do_not_track, 'do_not_track value'); const results = { neighbourhood: [ { @@ -258,7 +271,12 @@ module.exports.tests.success_conditions = (test, common) => { const should_execute = () => { return true; }; const controller = proxyquire('../../../controller/coarse_reverse', { - 'pelias-logger': logger + 'pelias-logger': logger, + '../helper/logging': { + isDNT: () => { + return 'do_not_track value'; + } + } })(service, should_execute); const req = { @@ -319,7 +337,8 @@ module.exports.tests.success_conditions = (test, common) => { }); test('most granular layer missing centroid should not set', (t) => { - const service = (point, callback) => { + const service = (point, do_not_track, callback) => { + t.equals(do_not_track, 'do_not_track value'); const results = { neighbourhood: [ { @@ -338,7 +357,12 @@ module.exports.tests.success_conditions = (test, common) => { const should_execute = () => { return true; }; const controller = proxyquire('../../../controller/coarse_reverse', { - 'pelias-logger': logger + 'pelias-logger': logger, + '../helper/logging': { + isDNT: () => { + return 'do_not_track value'; + } + } })(service, should_execute); const req = { @@ -395,7 +419,8 @@ module.exports.tests.success_conditions = (test, common) => { }); test('most granular layer missing bounding_box should not set', (t) => { - const service = (point, callback) => { + const service = (point, do_not_track, callback) => { + t.equals(do_not_track, 'do_not_track value'); const results = { neighbourhood: [ { @@ -417,7 +442,12 @@ module.exports.tests.success_conditions = (test, common) => { const should_execute = () => { return true; }; const controller = proxyquire('../../../controller/coarse_reverse', { - 'pelias-logger': logger + 'pelias-logger': logger, + '../helper/logging': { + isDNT: () => { + return 'do_not_track value'; + } + } })(service, should_execute); const req = { @@ -480,7 +510,8 @@ module.exports.tests.success_conditions = (test, common) => { module.exports.tests.failure_conditions = (test, common) => { test('service returning 0 results at the requested layer should return nothing', (t) => { - const service = (point, callback) => { + const service = (point, do_not_track, callback) => { + t.equals(do_not_track, 'do_not_track value'); // response without neighbourhood results const results = { borough: [ @@ -528,7 +559,12 @@ module.exports.tests.failure_conditions = (test, common) => { const should_execute = () => { return true; }; const controller = proxyquire('../../../controller/coarse_reverse', { - 'pelias-logger': logger + 'pelias-logger': logger, + '../helper/logging': { + isDNT: () => { + return 'do_not_track value'; + } + } })(service, should_execute); const req = { From 601478616207915211143fe1db0421acd4b5d844 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Wed, 19 Apr 2017 17:44:03 -0400 Subject: [PATCH 9/9] =?UTF-8?q?Revert=20"Update=20pelias-query=20to=20the?= =?UTF-8?q?=20latest=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