-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(search): use libpostal parses for venue queries where available
- Loading branch information
1 parent
893d7a0
commit d74b893
Showing
4 changed files
with
409 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
196 changes: 196 additions & 0 deletions
196
test/unit/fixture/search_fallback_venue_city_country.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
Oops, something went wrong.