Skip to content

Commit

Permalink
feat(query): improve unit number sorting for fallback.housenumber que…
Browse files Browse the repository at this point in the history
…ries
  • Loading branch information
missinglink committed Jan 21, 2025
1 parent c692c72 commit 0760212
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 10 deletions.
12 changes: 10 additions & 2 deletions layout/FallbackQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ function addUnitAndHouseNumberAndStreet(vs) {
analyzer: vs.var('address:street:analyzer')
})
],
should: [],
should: [
// non-numeric tokens are stripped from the index, use the phrase field to improve sorting.
// see: https://github.com/pelias/pelias/issues/810
match_phrase('phrase.default', vs.var('input:housenumber'))
],
filter: {
term: {
layer: 'address'
Expand Down Expand Up @@ -273,7 +277,11 @@ function addHouseNumberAndStreet(vs) {
analyzer: vs.var('address:street:analyzer')
})
],
should: [],
should: [
// non-numeric tokens are stripped from the index, use the phrase field to improve sorting.
// see: https://github.com/pelias/pelias/issues/810
match_phrase('phrase.default', vs.var('input:housenumber'))
],
filter: {
term: {
layer: 'address'
Expand Down
18 changes: 15 additions & 3 deletions layout/StructuredFallbackQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ function addUnitAndHouseNumberAndStreet(vs) {
match_phrase('address_parts.number', vs.var('input:housenumber')),
match_phrase('address_parts.street', vs.var('input:street'), { slop: vs.var('address:street:slop') })
],
should: [],
should: [
// non-numeric tokens are stripped from the index, use the phrase field to improve sorting.
// see: https://github.com/pelias/pelias/issues/810
match_phrase('phrase.default', vs.var('input:housenumber'))
],
filter: {
term: {
layer: 'address'
Expand Down Expand Up @@ -232,7 +236,11 @@ function addHouseNumber(vs) {
}
}
],
should: [],
should: [
// non-numeric tokens are stripped from the index, use the phrase field to improve sorting.
// see: https://github.com/pelias/pelias/issues/810
match_phrase('phrase.default', vs.var('input:housenumber'))
],
filter: {
term: {
layer: 'address'
Expand Down Expand Up @@ -264,7 +272,11 @@ function addHouseNumberAndStreet(vs) {
match_phrase('address_parts.number', vs.var('input:housenumber')),
match_phrase('address_parts.street', vs.var('input:street'), { slop: vs.var('address:street:slop') })
],
should: [],
should: [
// non-numeric tokens are stripped from the index, use the phrase field to improve sorting.
// see: https://github.com/pelias/pelias/issues/810
match_phrase('phrase.default', vs.var('input:housenumber'))
],
filter: {
term: {
layer: 'address'
Expand Down
10 changes: 9 additions & 1 deletion test/fixtures/fallbackQuery1.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,15 @@
}
}
],
"should": [],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "house number value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down
10 changes: 9 additions & 1 deletion test/fixtures/fallbackQuery2.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,15 @@
}
}
],
"should": [],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "house number value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/fallbackQuery_address_with_postcode.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
}
],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "house number value"
}
}
},
{
"match_phrase": {
"address_parts.zip": {
Expand Down
10 changes: 9 additions & 1 deletion test/fixtures/structuredFallbackQuery/address.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@
}
}
],
"should": [],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "house number value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
}
],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "house number value"
}
}
},
{
"match_phrase": {
"address_parts.zip": {
Expand Down
10 changes: 9 additions & 1 deletion test/fixtures/structuredFallbackQuery/housenumber.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@
}
}
],
"should": [],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "house number value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down
10 changes: 9 additions & 1 deletion test/fixtures/structuredFallbackQuery/query.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,15 @@
}
}
],
"should": [],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "house number value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down

0 comments on commit 0760212

Please sign in to comment.