Skip to content

Commit

Permalink
feat: Merge pull request #763 from pelias/add-query-support-to-struct…
Browse files Browse the repository at this point in the history
…ured

Add query support to structured
  • Loading branch information
trescube authored Jan 12, 2017
2 parents d5c251e + 992f245 commit 1f49886
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"pelias-labels": "1.5.1",
"pelias-logger": "0.1.0",
"pelias-model": "4.4.0",
"pelias-query": "8.11.0",
"pelias-query": "8.12.0",
"pelias-text-analyzer": "1.7.0",
"stats-lite": "2.0.3",
"through2": "^2.0.3"
Expand Down
1 change: 1 addition & 0 deletions sanitizer/_synthesize_analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const _ = require('lodash');
const text_analyzer = require('pelias-text-analyzer');

const fields = {
'venue': 'query',
'address': 'address',
'neighbourhood': 'neighbourhood',
'borough': 'borough',
Expand Down
90 changes: 90 additions & 0 deletions test/unit/fixture/structured_geocoding/fallback.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,96 @@
"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",
Expand Down
8 changes: 5 additions & 3 deletions test/unit/sanitizer/_synthesize_analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ',
Expand All @@ -26,6 +26,7 @@ module.exports.tests.text_parser = function(test, common) {

const expected_clean = {
parsed_text: {
query: 'venue value',
neighbourhood: 'neighbourhood value',
borough: 'borough value',
city: 'locality value',
Expand Down Expand Up @@ -58,6 +59,7 @@ module.exports.tests.text_parser = function(test, common) {
}

const raw = {
venue: getInvalidValue(),
address: getInvalidValue(),
neighbourhood: getInvalidValue(),
borough: getInvalidValue(),
Expand All @@ -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');
'venue, address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors');
t.deepEquals(messages.warnings, [], 'no warnings');
t.end();

Expand All @@ -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');
'venue, address, neighbourhood, borough, locality, county, region, postalcode, country'], 'no errors');
t.deepEquals(messages.warnings, [], 'no warnings');
t.end();

Expand Down

0 comments on commit 1f49886

Please sign in to comment.