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

improve unit number sorting for fallback.housenumber queries #139

Merged
merged 1 commit into from
Jan 22, 2025
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
15 changes: 15 additions & 0 deletions layout/AddressesUsingIdsQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ function createAddressShould(vs) {
analyzer: vs.var('address:street:analyzer')
})
],
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 @@ -40,6 +45,11 @@ function createUnitAndAddressShould(vs) {
analyzer: vs.var('address:street:analyzer')
})
],
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 @@ -67,6 +77,11 @@ function createPostcodeAndAddressShould(vs) {
analyzer: vs.var('address:street:analyzer')
})
],
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
}
}
],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "housenumber value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down
18 changes: 18 additions & 0 deletions test/fixtures/addressesUsingIdsQuery/no_layers.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
}
}
],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "housenumber value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down Expand Up @@ -83,6 +92,15 @@
}
}
],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "housenumber value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
}
}
],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "housenumber value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/addressesUsingIdsQuery/with_filters.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
}
}
],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "housenumber value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/addressesUsingIdsQuery/with_layers.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
}
}
],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "housenumber value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
}
}
],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "housenumber value"
}
}
}
],
"filter": {
"term": {
"layer": "address"
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/addressesUsingIdsQuery/with_scores.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
}
}
],
"should": [
{
"match_phrase": {
"phrase.default": {
"query": "housenumber value"
}
}
}
],
"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