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

[pull] master from pelias:master #16

Merged
merged 2 commits into from
May 5, 2022
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
4 changes: 2 additions & 2 deletions query/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ query.filter( peliasQuery.view.sources );
query.filter( peliasQuery.view.layers );
query.filter( peliasQuery.view.boundary_rect );
query.filter( peliasQuery.view.boundary_circle );
query.filter( peliasQuery.view.boundary_country );
query.filter( peliasQuery.view.leaf.multi_match('boundary_country') );
query.filter( peliasQuery.view.categories );
query.filter( peliasQuery.view.boundary_gid );
query.filter( views.focus_point_filter );
Expand Down Expand Up @@ -88,7 +88,7 @@ function generateQuery( clean ){
// boundary country
if( _.isArray(clean['boundary.country']) && !_.isEmpty(clean['boundary.country']) ){
vs.set({
'boundary:country': clean['boundary.country'].join(' ')
'multi_match:boundary_country:input': clean['boundary.country'].join(' ')
});
}

Expand Down
4 changes: 4 additions & 0 deletions query/autocomplete_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ module.exports = _.merge({}, peliasQuery.defaults, {
'admin:country_a:boost': 1,
'admin:country_a:cutoff_frequency': 0.01,

// these options affect the `boundary.country` hard filter
'multi_match:boundary_country:analyzer': 'standard',
'multi_match:boundary_country:fields': ['parent.country_a', 'parent.dependency_a'],

'admin:country:analyzer': 'peliasAdmin',
'admin:country:field': 'parent.country.ngram',
'admin:country:boost': 1,
Expand Down
4 changes: 2 additions & 2 deletions query/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fallbackQuery.score( peliasQuery.view.population_only_function );
// --------------------------------

// non-scoring hard filters
fallbackQuery.filter( peliasQuery.view.boundary_country );
fallbackQuery.filter( peliasQuery.view.leaf.multi_match('boundary_country') );
fallbackQuery.filter( peliasQuery.view.boundary_circle );
fallbackQuery.filter( peliasQuery.view.boundary_rect );
fallbackQuery.filter( peliasQuery.view.sources );
Expand Down Expand Up @@ -97,7 +97,7 @@ function generateQuery( clean ){
// boundary country
if( _.isArray(clean['boundary.country']) && !_.isEmpty(clean['boundary.country']) ){
vs.set({
'boundary:country': clean['boundary.country'].join(' ')
'multi_match:boundary_country:input': clean['boundary.country'].join(' ')
});
}

Expand Down
4 changes: 4 additions & 0 deletions query/search_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ module.exports = _.merge({}, peliasQuery.defaults, {
'admin:country_a:boost': 1,
'admin:country_a:cutoff_frequency': 0.01,

// these config variables are used for the 'boundary.country' hard filter
'multi_match:boundary_country:analyzer': 'standard',
'multi_match:boundary_country:fields': ['parent.country_a', 'parent.dependency_a'],

'admin:country:analyzer': 'peliasAdmin',
'admin:country:field': 'parent.country',
'admin:country:boost': 1,
Expand Down
4 changes: 2 additions & 2 deletions query/search_pelias_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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 );
query.filter( peliasQuery.view.leaf.multi_match('boundary_country') );
query.filter( peliasQuery.view.boundary_gid );

// --------------------------------
Expand Down Expand Up @@ -123,7 +123,7 @@ function generateQuery( clean ){
// boundary country
if( _.isArray(clean['boundary.country']) && !_.isEmpty(clean['boundary.country']) ){
vs.set({
'boundary:country': clean['boundary.country'].join(' ')
'multi_match:boundary_country:input': clean['boundary.country'].join(' ')
});
}

Expand Down
4 changes: 2 additions & 2 deletions query/structured_geocoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ structuredQuery.score( peliasQuery.view.population_only_function );
// --------------------------------

// non-scoring hard filters
structuredQuery.filter( peliasQuery.view.boundary_country );
structuredQuery.filter( peliasQuery.view.leaf.multi_match('boundary_country') );
structuredQuery.filter( peliasQuery.view.boundary_circle );
structuredQuery.filter( peliasQuery.view.boundary_rect );
structuredQuery.filter( peliasQuery.view.sources );
Expand Down Expand Up @@ -87,7 +87,7 @@ function generateQuery( clean ){
// boundary country
if( _.isArray(clean['boundary.country']) && !_.isEmpty(clean['boundary.country']) ){
vs.set({
'boundary:country': clean['boundary.country'].join(' ')
'multi_match:boundary_country:input': clean['boundary.country'].join(' ')
});
}

Expand Down
6 changes: 3 additions & 3 deletions test/unit/fixture/autocomplete_boundary_country.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ module.exports = {
}
}],
'filter': [{
'match': {
'parent.country_a.ngram': {
'multi_match': {
'type': 'best_fields',
'fields': ['parent.country_a', 'parent.dependency_a'],
'analyzer': 'standard',
'query': 'ABC'
}
}
}]
}
},
Expand Down
10 changes: 5 additions & 5 deletions test/unit/fixture/search_boundary_country.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ module.exports = {
'bool': {
'must': [
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
'multi_match': {
'type': 'best_fields',
'fields': ['parent.country_a', 'parent.dependency_a'],
'analyzer': 'standard',
'query': 'ABC'
}
},
{
Expand Down
10 changes: 5 additions & 5 deletions test/unit/fixture/search_boundary_country_multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ module.exports = {
'bool': {
'must': [
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC DEF'
}
'multi_match': {
'type': 'best_fields',
'fields': ['parent.country_a', 'parent.dependency_a'],
'analyzer': 'standard',
'query': 'ABC DEF'
}
},
{
Expand Down
10 changes: 5 additions & 5 deletions test/unit/fixture/search_pelias_parser_boundary_country.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ module.exports = {
}
},
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
'multi_match': {
'type': 'best_fields',
'fields': ['parent.country_a', 'parent.dependency_a'],
'analyzer': 'standard',
'query': 'ABC'
}
}
]
Expand Down
9 changes: 6 additions & 3 deletions test/unit/query/structured_geocoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const views = {
sources: 'sources view',
layers: 'layers view',
categories: 'categories view',
boundary_gid: 'boundary_gid view'
boundary_gid: 'boundary_gid view',
leaf: {
multi_match: () => 'multi_match leaf view'
}
};

module.exports.tests = {};
Expand Down Expand Up @@ -76,7 +79,7 @@ module.exports.tests.query = (test, common) => {
]);

t.deepEquals(query.body.filter_functions, [
'boundary_country view',
'multi_match leaf view',
'boundary_circle view',
'boundary_rect view',
'sources view',
Expand Down Expand Up @@ -592,7 +595,7 @@ module.exports.tests.boundary_country = (test, common) => {
}
})(clean);

t.equals(query.body.vs.var('boundary:country').toString(), 'boundary country value');
t.equals(query.body.vs.var('multi_match:boundary_country:input').toString(), 'boundary country value');

t.end();

Expand Down