From 16fc3bee6680268bf99d5170ecd0db062080919b Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Thu, 8 Dec 2016 09:25:56 -0500 Subject: [PATCH 1/5] synthesize query value from parameter --- sanitizer/_synthesize_analysis.js | 1 + test/unit/sanitizer/_synthesize_analysis.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sanitizer/_synthesize_analysis.js b/sanitizer/_synthesize_analysis.js index ab18b581..722038be 100644 --- a/sanitizer/_synthesize_analysis.js +++ b/sanitizer/_synthesize_analysis.js @@ -2,6 +2,7 @@ const _ = require('lodash'); const text_analyzer = require('pelias-text-analyzer'); const fields = { + 'query': 'query', 'address': 'address', 'neighbourhood': 'neighbourhood', 'borough': 'borough', diff --git a/test/unit/sanitizer/_synthesize_analysis.js b/test/unit/sanitizer/_synthesize_analysis.js index dabacef8..7ca374c3 100644 --- a/test/unit/sanitizer/_synthesize_analysis.js +++ b/test/unit/sanitizer/_synthesize_analysis.js @@ -26,6 +26,7 @@ module.exports.tests.text_parser = function(test, common) { const expected_clean = { parsed_text: { + query: 'query value', neighbourhood: 'neighbourhood value', borough: 'borough value', city: 'locality value', @@ -58,6 +59,7 @@ module.exports.tests.text_parser = function(test, common) { } const raw = { + query: getInvalidValue(), address: getInvalidValue(), neighbourhood: getInvalidValue(), borough: getInvalidValue(), @@ -78,7 +80,7 @@ module.exports.tests.text_parser = function(test, common) { t.deepEquals(clean, expected_clean); t.deepEquals(messages.errors, ['at least one of the following fields is required: ' + - 'address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors'); + 'query, address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors'); t.deepEquals(messages.warnings, [], 'no warnings'); t.end(); @@ -101,7 +103,7 @@ module.exports.tests.text_parser = function(test, common) { t.deepEquals(clean, expected_clean); t.deepEquals(messages.errors, ['at least one of the following fields is required: ' + - 'address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors'); + 'query, address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors'); t.deepEquals(messages.warnings, [], 'no warnings'); t.end(); From 8c896695d19468c7d25ab6bdabf9cb6162623fbf Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Fri, 9 Dec 2016 15:16:38 -0500 Subject: [PATCH 2/5] tied query version to specific hash, updated tests --- package.json | 2 +- .../structured_geocoding/fallback.json | 89 +++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9059f0a9..4bd39d62 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "pelias-labels": "1.5.1", "pelias-logger": "0.1.0", "pelias-model": "4.4.0", - "pelias-query": "8.11.0", + "pelias-query": "pelias/query#b3e2ef7", "pelias-text-analyzer": "1.7.0", "stats-lite": "2.0.3", "through2": "^2.0.3" diff --git a/test/unit/fixture/structured_geocoding/fallback.json b/test/unit/fixture/structured_geocoding/fallback.json index a957b72c..6bea84fc 100644 --- a/test/unit/fixture/structured_geocoding/fallback.json +++ b/test/unit/fixture/structured_geocoding/fallback.json @@ -6,6 +6,95 @@ "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": { "_name": "fallback.address", From bb285cf0a56df10004a2f4dbbb4953565d5b27c2 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Fri, 9 Dec 2016 17:20:03 -0500 Subject: [PATCH 3/5] bumped query hash, updated test --- package.json | 2 +- test/unit/fixture/structured_geocoding/fallback.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4bd39d62..9b4af449 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "pelias-labels": "1.5.1", "pelias-logger": "0.1.0", "pelias-model": "4.4.0", - "pelias-query": "pelias/query#b3e2ef7", + "pelias-query": "pelias/query#fe42de6", "pelias-text-analyzer": "1.7.0", "stats-lite": "2.0.3", "through2": "^2.0.3" diff --git a/test/unit/fixture/structured_geocoding/fallback.json b/test/unit/fixture/structured_geocoding/fallback.json index 6bea84fc..cd12a864 100644 --- a/test/unit/fixture/structured_geocoding/fallback.json +++ b/test/unit/fixture/structured_geocoding/fallback.json @@ -15,7 +15,8 @@ "query": "query value", "type": "phrase", "fields": [ - "phrase.default" + "phrase.default", + "category" ] } }, From 5a146d2efea7673bd004b20d02cd6884cf425b2a Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Fri, 16 Dec 2016 16:49:53 -0500 Subject: [PATCH 4/5] bumped query package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9b4af449..055f7c61 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "pelias-labels": "1.5.1", "pelias-logger": "0.1.0", "pelias-model": "4.4.0", - "pelias-query": "pelias/query#fe42de6", + "pelias-query": "8.12.0", "pelias-text-analyzer": "1.7.0", "stats-lite": "2.0.3", "through2": "^2.0.3" From 992f2455d5c73ee80c54633e538aca60fb7df836 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Thu, 12 Jan 2017 15:36:04 -0500 Subject: [PATCH 5/5] renamed `query` parameter to `venue` --- sanitizer/_synthesize_analysis.js | 2 +- test/unit/sanitizer/_synthesize_analysis.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sanitizer/_synthesize_analysis.js b/sanitizer/_synthesize_analysis.js index 722038be..f26dfc6a 100644 --- a/sanitizer/_synthesize_analysis.js +++ b/sanitizer/_synthesize_analysis.js @@ -2,7 +2,7 @@ const _ = require('lodash'); const text_analyzer = require('pelias-text-analyzer'); const fields = { - 'query': 'query', + 'venue': 'query', 'address': 'address', 'neighbourhood': 'neighbourhood', 'borough': 'borough', diff --git a/test/unit/sanitizer/_synthesize_analysis.js b/test/unit/sanitizer/_synthesize_analysis.js index 7ca374c3..97d49b2a 100644 --- a/test/unit/sanitizer/_synthesize_analysis.js +++ b/test/unit/sanitizer/_synthesize_analysis.js @@ -12,7 +12,7 @@ module.exports.tests.text_parser = function(test, common) { }}); const raw = { - query: ' \t query \t value \t ', + venue: ' \t venue \t value \t ', neighbourhood: ' \t neighbourhood \t value \t ', borough: ' \t borough \t value \t ', locality: ' \t locality \t value \t ', @@ -26,7 +26,7 @@ module.exports.tests.text_parser = function(test, common) { const expected_clean = { parsed_text: { - query: 'query value', + query: 'venue value', neighbourhood: 'neighbourhood value', borough: 'borough value', city: 'locality value', @@ -59,7 +59,7 @@ module.exports.tests.text_parser = function(test, common) { } const raw = { - query: getInvalidValue(), + venue: getInvalidValue(), address: getInvalidValue(), neighbourhood: getInvalidValue(), borough: getInvalidValue(), @@ -80,7 +80,7 @@ module.exports.tests.text_parser = function(test, common) { t.deepEquals(clean, expected_clean); t.deepEquals(messages.errors, ['at least one of the following fields is required: ' + - 'query, address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors'); + 'venue, address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors'); t.deepEquals(messages.warnings, [], 'no warnings'); t.end(); @@ -103,7 +103,7 @@ module.exports.tests.text_parser = function(test, common) { t.deepEquals(clean, expected_clean); t.deepEquals(messages.errors, ['at least one of the following fields is required: ' + - 'query, address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors'); + 'venue, address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors'); t.deepEquals(messages.warnings, [], 'no warnings'); t.end();