Browse Source

Merge pull request #1212 from pelias/boundary-country-to-filter

fix(boundary.country): use boundary.country query as filter
pull/1214/head
Julian Simioni 6 years ago committed by GitHub
parent
commit
97b5e9d2ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      query/autocomplete.js
  2. 3
      query/reverse.js
  3. 2
      query/search_original.js
  4. 15
      test/unit/fixture/autocomplete_boundary_country.js
  5. 16
      test/unit/fixture/search_boundary_country_original.js
  6. 4
      test/unit/query/reverse.js

2
query/autocomplete.js

@ -21,7 +21,6 @@ var query = new peliasQuery.layout.FilteredBooleanQuery();
// mandatory matches
query.score( views.phrase_first_tokens_only, 'must' );
query.score( views.ngrams_last_token_only, 'must' );
query.score( peliasQuery.view.boundary_country, 'must' );
// address components
query.score( peliasQuery.view.address('housenumber') );
@ -49,6 +48,7 @@ query.score( peliasQuery.view.population( views.pop_subquery ) );
query.filter( peliasQuery.view.sources );
query.filter( peliasQuery.view.layers );
query.filter( peliasQuery.view.boundary_rect );
query.filter( peliasQuery.view.boundary_country );
// --------------------------------

3
query/reverse.js

@ -10,7 +10,7 @@ const logger = require('pelias-logger').get('api');
var query = new peliasQuery.layout.FilteredBooleanQuery();
// mandatory matches
query.score( peliasQuery.view.boundary_country, 'must' );
// (none)
// scoring boost
query.sort( peliasQuery.view.sort_distance );
@ -20,6 +20,7 @@ query.filter( peliasQuery.view.boundary_circle );
query.filter( peliasQuery.view.sources );
query.filter( peliasQuery.view.layers );
query.filter( peliasQuery.view.categories );
query.filter( peliasQuery.view.boundary_country );
// --------------------------------

2
query/search_original.js

@ -18,7 +18,6 @@ var adminFields = placeTypes.concat(['region_a']);
var query = new peliasQuery.layout.FilteredBooleanQuery();
// mandatory matches
query.score( peliasQuery.view.boundary_country, 'must' );
query.score( peliasQuery.view.ngrams, 'must' );
// scoring boost
@ -46,6 +45,7 @@ query.filter( peliasQuery.view.boundary_rect );
query.filter( peliasQuery.view.sources );
query.filter( peliasQuery.view.layers );
query.filter( peliasQuery.view.categories );
query.filter( peliasQuery.view.boundary_country );
// --------------------------------

15
test/unit/fixture/autocomplete_boundary_country.js

@ -16,13 +16,6 @@ module.exports = {
}
}
}
}, {
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
}
}],
'should':[{
'function_score': {
@ -58,6 +51,14 @@ module.exports = {
'weight': 3
}]
}
}],
'filter': [{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
}
}]
}
},

16
test/unit/fixture/search_boundary_country_original.js

@ -2,14 +2,6 @@ module.exports = {
'query': {
'bool': {
'must': [
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
}
},
{
'match': {
'name.default': {
@ -88,6 +80,14 @@ module.exports = {
'test'
]
}
},
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
}
}
]
}

4
test/unit/query/reverse.js

@ -56,14 +56,14 @@ module.exports.tests.query = (test, common) => {
t.notOk(query.body.vs.isset('input:categories'));
t.deepEquals(query.body.score_functions, [
'boundary_country view'
]);
t.deepEquals(query.body.filter_functions, [
'boundary_circle view',
'sources view',
'layers view',
'categories view'
'categories view',
'boundary_country view'
]);
t.deepEquals(query.body.sort_functions, [

Loading…
Cancel
Save