Skip to content

Commit ea5f89c

Browse files
committed
feat(query): improve unit number sorting for fallback.housenumber queries
1 parent c692c72 commit ea5f89c

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

layout/StructuredFallbackQuery.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ function addHouseNumberAndStreet(vs) {
264264
match_phrase('address_parts.number', vs.var('input:housenumber')),
265265
match_phrase('address_parts.street', vs.var('input:street'), { slop: vs.var('address:street:slop') })
266266
],
267-
should: [],
267+
should: [
268+
// non-numeric tokens are stripped from the index, use the phrase field to improve sorting.
269+
// see: https://github.com/pelias/pelias/issues/810
270+
match_phrase('phrase.default', vs.var('input:housenumber'))
271+
],
268272
filter: {
269273
term: {
270274
layer: 'address'

test/fixtures/structuredFallbackQuery/address_with_postcode.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
}
2727
],
2828
"should": [
29+
{
30+
"match_phrase": {
31+
"phrase.default": {
32+
"query": "house number value"
33+
}
34+
}
35+
},
2936
{
3037
"match_phrase": {
3138
"address_parts.zip": {

test/fixtures/structuredFallbackQuery/query.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,15 @@
183183
}
184184
}
185185
],
186-
"should": [],
186+
"should": [
187+
{
188+
"match_phrase": {
189+
"phrase.default": {
190+
"query": "house number value"
191+
}
192+
}
193+
}
194+
],
187195
"filter": {
188196
"term": {
189197
"layer": "address"

0 commit comments

Comments
 (0)