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

use libpostal parses for venue queries where available #1380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion query/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function generateQuery( clean ){
}

function getQuery(vs) {
if (hasStreet(vs) || isPostalCodeOnly(vs) || isPostalCodeWithAdmin(vs)) {
if (hasStreet(vs) || isPostalCodeOnly(vs) || isPostalCodeWithAdmin(vs) || isVenue(vs)) {
return {
type: 'search_fallback',
body: fallbackQuery.render(vs)
Expand Down Expand Up @@ -156,6 +156,10 @@ function hasStreet(vs) {
return vs.isset('input:street');
}

function isVenue(vs) {
return determineQueryType(vs) === 'venue';
}

function isPostalCodeOnly(vs) {
var isSet = layer => vs.isset(`input:${layer}`);

Expand Down
196 changes: 196 additions & 0 deletions test/unit/fixture/search_fallback_venue_city_country.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
module.exports = {
'query': {
'function_score': {
'query': {
'bool': {
'minimum_should_match': 1,
'should': [
{
'bool': {
'_name': 'fallback.venue',
'must': [
{
'multi_match': {
'query': 'query value',
'type': 'phrase',
'fields': [
'phrase.default'
]
}
},
{
'multi_match': {
'query': 'city value',
'type': 'phrase',
'fields': [
'parent.locality',
'parent.locality_a',
'parent.localadmin',
'parent.localadmin_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.locality',
'must': [
{
'multi_match': {
'query': 'city value',
'type': 'phrase',
'fields': [
'parent.locality',
'parent.locality_a'
]
}
},
{
'multi_match': {
'query': 'country value',
'type': 'phrase',
'fields': [
'parent.country',
'parent.country_a',
'parent.dependency',
'parent.dependency_a'
]
}
}
],
'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': 'country value',
'type': 'phrase',
'fields': [
'parent.country',
'parent.country_a',
'parent.dependency',
'parent.dependency_a'
]
}
}
],
'filter': {
'term': {
'layer': 'localadmin'
}
}
}
},
{
'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,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}
],
'score_mode': 'avg',
'boost_mode': 'multiply'
}
},
'sort': [
'_score'
],
'size': 20,
'track_scores': true
};
Loading