Skip to content

Commit

Permalink
Merge pull request #100 from pelias/use-full-match_phrase-query
Browse files Browse the repository at this point in the history
feat(query): Use full form for match_phrase query
  • Loading branch information
orangejulius authored Jun 18, 2019
2 parents ae3912b + f7f4d50 commit ca7ddd6
Show file tree
Hide file tree
Showing 19 changed files with 246 additions and 82 deletions.
36 changes: 27 additions & 9 deletions layout/AddressesUsingIdsQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ function createAddressShould(vs) {
must: [
{
match_phrase: {
'address_parts.number': vs.var('input:housenumber')
'address_parts.number': {
query: vs.var('input:housenumber')
}
}
},
{
match_phrase: {
'address_parts.street': vs.var('input:street')
'address_parts.street': {
query: vs.var('input:street')
}
}
}
],
Expand All @@ -41,17 +45,23 @@ function createUnitAndAddressShould(vs) {
must: [
{
match_phrase: {
'address_parts.unit': vs.var('input:unit')
'address_parts.unit': {
query: vs.var('input:unit')
}
}
},
{
match_phrase: {
'address_parts.number': vs.var('input:housenumber')
'address_parts.number': {
query: vs.var('input:housenumber')
}
}
},
{
match_phrase: {
'address_parts.street': vs.var('input:street')
'address_parts.street': {
query: vs.var('input:street')
}
}
}
],
Expand All @@ -77,17 +87,23 @@ function createPostcodeAndAddressShould(vs) {
must: [
{
match_phrase: {
'address_parts.zip': vs.var('input:postcode')
'address_parts.zip': {
query: vs.var('input:postcode')
}
}
},
{
match_phrase: {
'address_parts.number': vs.var('input:housenumber')
'address_parts.number': {
query: vs.var('input:housenumber')
}
}
},
{
match_phrase: {
'address_parts.street': vs.var('input:street')
'address_parts.street': {
query: vs.var('input:street')
}
}
}
],
Expand All @@ -113,7 +129,9 @@ function createStreetShould(vs) {
must: [
{
match_phrase: {
'address_parts.street': vs.var('input:street')
'address_parts.street': {
query: vs.var('input:street')
}
}
}
],
Expand Down
32 changes: 24 additions & 8 deletions layout/FallbackQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ function addPrimary(value, layer, fields, likely_to_have_abbreviation) {
// o.bool.must.push(
// {
// match_phrase: {
// 'phrase.default': value
// 'phrase.default': {
// query: value
// }
// }
// }
// );
Expand Down Expand Up @@ -110,7 +112,9 @@ function addSecPostCode(vs, o) {
if (vs.isset('input:postcode')) {
o.bool.should.push({
match_phrase: {
'address_parts.zip': vs.var('input:postcode').toString()
'address_parts.zip': {
query: vs.var('input:postcode').toString()
}
}
});
}
Expand Down Expand Up @@ -231,17 +235,23 @@ function addUnitAndHouseNumberAndStreet(vs) {
must: [
{
match_phrase: {
'address_parts.unit': vs.var('input:unit').toString()
'address_parts.unit': {
query: vs.var('input:unit').toString()
}
}
},
{
match_phrase: {
'address_parts.number': vs.var('input:housenumber').toString()
'address_parts.number': {
query: vs.var('input:housenumber').toString()
}
}
},
{
match_phrase: {
'address_parts.street': vs.var('input:street').toString()
'address_parts.street': {
query: vs.var('input:street').toString()
}
}
}
],
Expand Down Expand Up @@ -277,12 +287,16 @@ function addHouseNumberAndStreet(vs) {
must: [
{
match_phrase: {
'address_parts.number': vs.var('input:housenumber').toString()
'address_parts.number': {
query: vs.var('input:housenumber').toString()
}
}
},
{
match_phrase: {
'address_parts.street': vs.var('input:street').toString()
'address_parts.street': {
query: vs.var('input:street').toString()
}
}
}
],
Expand Down Expand Up @@ -318,7 +332,9 @@ function addStreet(vs) {
must: [
{
match_phrase: {
'address_parts.street': vs.var('input:street').toString()
'address_parts.street': {
query: vs.var('input:street').toString()
}
}
}
],
Expand Down
32 changes: 24 additions & 8 deletions layout/StructuredFallbackQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ function addSecPostCode(vs, o) {
if (vs.isset('input:postcode')) {
o.bool.should.push({
match_phrase: {
'address_parts.zip': vs.var('input:postcode').toString()
'address_parts.zip': {
query: vs.var('input:postcode').toString()
}
}
});
}
Expand Down Expand Up @@ -192,17 +194,23 @@ function addUnitAndHouseNumberAndStreet(vs) {
must: [
{
match_phrase: {
'address_parts.unit': vs.var('input:unit').toString()
'address_parts.unit': {
query: vs.var('input:unit').toString()
}
}
},
{
match_phrase: {
'address_parts.number': vs.var('input:housenumber').toString()
'address_parts.number': {
query: vs.var('input:housenumber').toString()
}
}
},
{
match_phrase: {
'address_parts.street': vs.var('input:street').toString()
'address_parts.street': {
query: vs.var('input:street').toString()
}
}
}
],
Expand Down Expand Up @@ -238,7 +246,9 @@ function addHouseNumber(vs) {
must: [
{
match_phrase: {
'address_parts.number': vs.var('input:housenumber').toString()
'address_parts.number': {
query: vs.var('input:housenumber').toString()
}
}
}
],
Expand Down Expand Up @@ -273,12 +283,16 @@ function addHouseNumberAndStreet(vs) {
must: [
{
match_phrase: {
'address_parts.number': vs.var('input:housenumber').toString()
'address_parts.number': {
query: vs.var('input:housenumber').toString()
}
}
},
{
match_phrase: {
'address_parts.street': vs.var('input:street').toString()
'address_parts.street': {
query: vs.var('input:street').toString()
}
}
}
],
Expand Down Expand Up @@ -314,7 +328,9 @@ function addStreet(vs) {
must: [
{
match_phrase: {
'address_parts.street': vs.var('input:street').toString()
'address_parts.street': {
query: vs.var('input:street').toString()
}
}
}
],
Expand Down
12 changes: 9 additions & 3 deletions test/fixtures/addressesUsingIdsQuery/housenumber_no_units.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"must": [
{
"match_phrase": {
"address_parts.street": "street value"
"address_parts.street": {
"query": "street value"
}
}
}
],
Expand All @@ -28,12 +30,16 @@
"must": [
{
"match_phrase": {
"address_parts.number": "housenumber value"
"address_parts.number": {
"query": "housenumber value"
}
}
},
{
"match_phrase": {
"address_parts.street": "street value"
"address_parts.street": {
"query": "street value"
}
}
}
],
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/addressesUsingIdsQuery/no_housenumber.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"must": [
{
"match_phrase": {
"address_parts.street": "street value"
"address_parts.street": {
"query": "street value"
}
}
}
],
Expand Down
28 changes: 21 additions & 7 deletions test/fixtures/addressesUsingIdsQuery/no_layers.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"must": [
{
"match_phrase": {
"address_parts.street": "street value"
"address_parts.street": {
"query": "street value"
}
}
}
],
Expand All @@ -28,17 +30,23 @@
"must": [
{
"match_phrase": {
"address_parts.zip": "postcode value"
"address_parts.zip": {
"query": "postcode value"
}
}
},
{
"match_phrase": {
"address_parts.number": "housenumber value"
"address_parts.number": {
"query": "housenumber value"
}
}
},
{
"match_phrase": {
"address_parts.street": "street value"
"address_parts.street": {
"query": "street value"
}
}
}
],
Expand All @@ -55,17 +63,23 @@
"must": [
{
"match_phrase": {
"address_parts.unit": "unit value"
"address_parts.unit": {
"query": "unit value"
}
}
},
{
"match_phrase": {
"address_parts.number": "housenumber value"
"address_parts.number": {
"query": "housenumber value"
}
}
},
{
"match_phrase": {
"address_parts.street": "street value"
"address_parts.street": {
"query": "street value"
}
}
}
],
Expand Down
16 changes: 12 additions & 4 deletions test/fixtures/addressesUsingIdsQuery/no_layers_with_boosts.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"must": [
{
"match_phrase": {
"address_parts.street": "street value"
"address_parts.street": {
"query": "street value"
}
}
}
],
Expand All @@ -30,17 +32,23 @@
"must": [
{
"match_phrase": {
"address_parts.unit": "unit value"
"address_parts.unit": {
"query": "unit value"
}
}
},
{
"match_phrase": {
"address_parts.number": "housenumber value"
"address_parts.number": {
"query": "housenumber value"
}
}
},
{
"match_phrase": {
"address_parts.street": "street value"
"address_parts.street": {
"query": "street value"
}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"must": [
{
"match_phrase": {
"address_parts.street": "street value"
"address_parts.street": {
"query": "street value"
}
}
}
],
Expand Down
Loading

0 comments on commit ca7ddd6

Please sign in to comment.