diff --git a/layout/FallbackQuery.js b/layout/FallbackQuery.js index 7e5972e..86230bc 100644 --- a/layout/FallbackQuery.js +++ b/layout/FallbackQuery.js @@ -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' @@ -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' diff --git a/layout/StructuredFallbackQuery.js b/layout/StructuredFallbackQuery.js index 7e21a39..86c80f3 100644 --- a/layout/StructuredFallbackQuery.js +++ b/layout/StructuredFallbackQuery.js @@ -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' @@ -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' @@ -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' diff --git a/test/fixtures/fallbackQuery1.json b/test/fixtures/fallbackQuery1.json index 18ec92d..22c5023 100644 --- a/test/fixtures/fallbackQuery1.json +++ b/test/fixtures/fallbackQuery1.json @@ -189,7 +189,15 @@ } } ], - "should": [], + "should": [ + { + "match_phrase": { + "phrase.default": { + "query": "house number value" + } + } + } + ], "filter": { "term": { "layer": "address" diff --git a/test/fixtures/fallbackQuery2.json b/test/fixtures/fallbackQuery2.json index a62d02c..b7598c4 100644 --- a/test/fixtures/fallbackQuery2.json +++ b/test/fixtures/fallbackQuery2.json @@ -93,7 +93,15 @@ } } ], - "should": [], + "should": [ + { + "match_phrase": { + "phrase.default": { + "query": "house number value" + } + } + } + ], "filter": { "term": { "layer": "address" diff --git a/test/fixtures/fallbackQuery_address_with_postcode.json b/test/fixtures/fallbackQuery_address_with_postcode.json index 9ed3d3c..09fc8d6 100644 --- a/test/fixtures/fallbackQuery_address_with_postcode.json +++ b/test/fixtures/fallbackQuery_address_with_postcode.json @@ -26,6 +26,13 @@ } ], "should": [ + { + "match_phrase": { + "phrase.default": { + "query": "house number value" + } + } + }, { "match_phrase": { "address_parts.zip": { diff --git a/test/fixtures/structuredFallbackQuery/address.json b/test/fixtures/structuredFallbackQuery/address.json index 1602305..4d88599 100644 --- a/test/fixtures/structuredFallbackQuery/address.json +++ b/test/fixtures/structuredFallbackQuery/address.json @@ -100,7 +100,15 @@ } } ], - "should": [], + "should": [ + { + "match_phrase": { + "phrase.default": { + "query": "house number value" + } + } + } + ], "filter": { "term": { "layer": "address" diff --git a/test/fixtures/structuredFallbackQuery/address_with_postcode.json b/test/fixtures/structuredFallbackQuery/address_with_postcode.json index 65769db..59047dc 100644 --- a/test/fixtures/structuredFallbackQuery/address_with_postcode.json +++ b/test/fixtures/structuredFallbackQuery/address_with_postcode.json @@ -26,6 +26,13 @@ } ], "should": [ + { + "match_phrase": { + "phrase.default": { + "query": "house number value" + } + } + }, { "match_phrase": { "address_parts.zip": { diff --git a/test/fixtures/structuredFallbackQuery/housenumber.json b/test/fixtures/structuredFallbackQuery/housenumber.json index a692ec0..187d30f 100644 --- a/test/fixtures/structuredFallbackQuery/housenumber.json +++ b/test/fixtures/structuredFallbackQuery/housenumber.json @@ -18,7 +18,15 @@ } } ], - "should": [], + "should": [ + { + "match_phrase": { + "phrase.default": { + "query": "house number value" + } + } + } + ], "filter": { "term": { "layer": "address" diff --git a/test/fixtures/structuredFallbackQuery/query.json b/test/fixtures/structuredFallbackQuery/query.json index 17a7e35..39f71d7 100644 --- a/test/fixtures/structuredFallbackQuery/query.json +++ b/test/fixtures/structuredFallbackQuery/query.json @@ -183,7 +183,15 @@ } } ], - "should": [], + "should": [ + { + "match_phrase": { + "phrase.default": { + "query": "house number value" + } + } + } + ], "filter": { "term": { "layer": "address"