Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query support to structured #763

Merged
merged 5 commits into from
Jan 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "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