Browse Source

enabled all scores and filters

adjusted tests to account for new querying strategies, renamed all existing test fixture files to `*_original`.  pointed query module to a PR for testing.
pull/666/head
Stephen Hess 8 years ago
parent
commit
876782ed3a
  1. 2
      package.json
  2. 53
      query/search.js
  3. 130
      test/unit/fixture/search_boundary_country.js
  4. 99
      test/unit/fixture/search_boundary_country_original.js
  5. 1024
      test/unit/fixture/search_fallback.js
  6. 0
      test/unit/fixture/search_full_address_original.js
  7. 480
      test/unit/fixture/search_geodisambiguation.js
  8. 134
      test/unit/fixture/search_linguistic_bbox.js
  9. 98
      test/unit/fixture/search_linguistic_bbox_original.js
  10. 154
      test/unit/fixture/search_linguistic_focus.js
  11. 174
      test/unit/fixture/search_linguistic_focus_bbox.js
  12. 128
      test/unit/fixture/search_linguistic_focus_bbox_original.js
  13. 154
      test/unit/fixture/search_linguistic_focus_null_island.js
  14. 117
      test/unit/fixture/search_linguistic_focus_null_island_original.js
  15. 119
      test/unit/fixture/search_linguistic_focus_original.js
  16. 114
      test/unit/fixture/search_linguistic_only.js
  17. 89
      test/unit/fixture/search_linguistic_only_original.js
  18. 156
      test/unit/fixture/search_linguistic_viewport.js
  19. 159
      test/unit/fixture/search_linguistic_viewport_min_diagonal.js
  20. 0
      test/unit/fixture/search_partial_address_original.js
  21. 0
      test/unit/fixture/search_regions_address_original.js
  22. 116
      test/unit/fixture/search_with_category_filtering.js
  23. 86
      test/unit/fixture/search_with_category_filtering_original.js
  24. 112
      test/unit/fixture/search_with_source_filtering.js
  25. 85
      test/unit/fixture/search_with_source_filtering_original.js
  26. 295
      test/unit/query/search.js
  27. 22
      test/unit/query/search_original.js

2
package.json

@ -55,7 +55,7 @@
"pelias-config": "2.1.0", "pelias-config": "2.1.0",
"pelias-logger": "0.0.8", "pelias-logger": "0.0.8",
"pelias-model": "4.2.0", "pelias-model": "4.2.0",
"pelias-query": "8.5.0", "pelias-query": "pelias/query#f890a72",
"pelias-text-analyzer": "1.3.0", "pelias-text-analyzer": "1.3.0",
"stats-lite": "2.0.3", "stats-lite": "2.0.3",
"through2": "2.0.1" "through2": "2.0.1"

53
query/search.js

@ -7,43 +7,32 @@ var peliasQuery = require('pelias-query'),
// general-purpose search query // general-purpose search query
//------------------------------ //------------------------------
var fallbackQuery = new peliasQuery.layout.FallbackQuery(); var fallbackQuery = new peliasQuery.layout.FallbackQuery();
fallbackQuery.score( peliasQuery.view.popularity( peliasQuery.view.phrase ) );
fallbackQuery.score( peliasQuery.view.population( peliasQuery.view.phrase ) );
var geodisambiguationQuery = new peliasQuery.layout.GeodisambiguationQuery(); var geodisambiguationQuery = new peliasQuery.layout.GeodisambiguationQuery();
geodisambiguationQuery.score( peliasQuery.view.popularity( peliasQuery.view.phrase ) );
geodisambiguationQuery.score( peliasQuery.view.population( peliasQuery.view.phrase ) );
// mandatory matches
// query.score( peliasQuery.view.boundary_country, 'must' );
// query.score( peliasQuery.view.ngrams, 'must' );
// scoring boost // scoring boost
// query.score( peliasQuery.view.phrase ); fallbackQuery.score( peliasQuery.view.focus_only_function( peliasQuery.view.phrase ) );
// query.score( peliasQuery.view.focus( peliasQuery.view.phrase ) ); fallbackQuery.score( peliasQuery.view.popularity_only_function );
// query.score( peliasQuery.view.popularity( peliasQuery.view.phrase ) ); fallbackQuery.score( peliasQuery.view.population_only_function );
// query.score( peliasQuery.view.population( peliasQuery.view.phrase ) );
geodisambiguationQuery.score( peliasQuery.view.focus_only_function( peliasQuery.view.phrase ) );
// address components geodisambiguationQuery.score( peliasQuery.view.popularity_only_function );
// query.score( peliasQuery.view.address('housenumber'), 'must' ); geodisambiguationQuery.score( peliasQuery.view.population_only_function );
// query.score( peliasQuery.view.address('street'), 'must' ); // --------------------------------
// query.score( peliasQuery.view.address('postcode'), 'must' );
// admin components
// country_a and region_a are left as matches here because the text-analyzer
// can sometimes detect them, in which case a query more specific than a
// multi_match is appropriate.
// query.score( peliasQuery.view.admin('country_a'), 'must' );
// query.score( peliasQuery.view.admin('region_a'), 'must' );
// query.score( peliasQuery.view.admin('locality'), 'must' );
// query.score( peliasQuery.view.admin_multi_match(adminFields, 'peliasAdmin') );
// non-scoring hard filters // non-scoring hard filters
// query.filter( peliasQuery.view.boundary_circle ); fallbackQuery.filter( peliasQuery.view.boundary_country );
// query.filter( peliasQuery.view.boundary_rect ); fallbackQuery.filter( peliasQuery.view.boundary_circle );
// query.filter( peliasQuery.view.sources ); fallbackQuery.filter( peliasQuery.view.boundary_rect );
// query.filter( peliasQuery.view.layers ); fallbackQuery.filter( peliasQuery.view.sources );
// query.filter( peliasQuery.view.categories ); fallbackQuery.filter( peliasQuery.view.layers );
fallbackQuery.filter( peliasQuery.view.categories );
geodisambiguationQuery.filter( peliasQuery.view.boundary_country );
geodisambiguationQuery.filter( peliasQuery.view.boundary_circle );
geodisambiguationQuery.filter( peliasQuery.view.boundary_rect );
geodisambiguationQuery.filter( peliasQuery.view.sources );
geodisambiguationQuery.filter( peliasQuery.view.layers );
geodisambiguationQuery.filter( peliasQuery.view.categories );
// -------------------------------- // --------------------------------
/** /**

130
test/unit/fixture/search_boundary_country.js

@ -1,99 +1,59 @@
module.exports = { module.exports = {
'query': { 'query': {
'bool': { 'function_score': {
'must': [ 'query': {
{ 'filtered': {
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
}
},
{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}
],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': { 'query': {
'match': { 'bool': {
'phrase.default': { 'should': []
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, },
'max_boost': 20, 'filter': {
'score_mode': 'first', 'bool': {
'boost_mode': 'replace', 'must': [
'functions': [{ {
'field_value_factor': { 'match': {
'modifier': 'log1p', 'parent.country_a': {
'field': 'popularity', 'analyzer': 'standard',
'missing': 1 'query': 'ABC'
}, }
'weight': 1 }
}] },
} {
},{ 'terms': {
'function_score': { 'layer': [
'query': { 'test'
'match': { ]
'phrase.default': { }
'query': 'test', }
'analyzer': 'peliasPhrase', ]
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, }
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
} }
}], },
'filter': [ 'max_boost': 20,
'functions': [
{ {
'terms': { 'field_value_factor': {
'layer': [ 'modifier': 'log1p',
'test' 'field': 'popularity',
] 'missing': 1
} },
'weight': 1
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
} }
] ],
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, },
'sort': [ '_score' ],
'size': 10, 'size': 10,
'track_scores': true 'track_scores': true
}; };

99
test/unit/fixture/search_boundary_country_original.js

@ -0,0 +1,99 @@
module.exports = {
'query': {
'bool': {
'must': [
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
}
},
{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}
],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter': [
{
'terms': {
'layer': [
'test'
]
}
}
]
}
},
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};

1024
test/unit/fixture/search_fallback.js

File diff suppressed because it is too large Load Diff

0
test/unit/fixture/search_full_address.js → test/unit/fixture/search_full_address_original.js

480
test/unit/fixture/search_geodisambiguation.js

@ -1,254 +1,252 @@
module.exports = { module.exports = {
'query': { 'query': {
'bool': { 'function_score': {
'should': [ 'query': {
{ 'filtered': {
'bool': { 'query': {
'must': [ 'bool': {
{ 'should': [
'multi_match': { {
'query': 'neighbourhood value', 'bool': {
'type': 'phrase', 'must': [
'fields': [ {
'parent.neighbourhood', 'multi_match': {
'parent.neighbourhood_a' 'query': 'neighbourhood value',
] 'type': 'phrase',
} 'fields': [
} 'parent.neighbourhood',
], 'parent.neighbourhood_a'
'filter': { ]
'term': { }
'layer': 'neighbourhood' }
} ],
} 'filter': {
} 'term': {
}, 'layer': 'neighbourhood'
{ }
'bool': { }
'must': [ }
{ },
'multi_match': { {
'query': 'neighbourhood value', 'bool': {
'type': 'phrase', 'must': [
'fields': [ {
'parent.borough', 'multi_match': {
'parent.borough_a' 'query': 'neighbourhood value',
] 'type': 'phrase',
} 'fields': [
} 'parent.borough',
], 'parent.borough_a'
'filter': { ]
'term': { }
'layer': 'borough' }
} ],
} 'filter': {
} 'term': {
}, 'layer': 'borough'
{ }
'bool': { }
'must': [ }
{ },
'multi_match': { {
'query': 'neighbourhood value', 'bool': {
'type': 'phrase', 'must': [
'fields': [ {
'parent.locality', 'multi_match': {
'parent.locality_a' 'query': 'neighbourhood value',
] 'type': 'phrase',
} 'fields': [
} 'parent.locality',
], 'parent.locality_a'
'filter': { ]
'term': { }
'layer': 'locality' }
} ],
} 'filter': {
} 'term': {
}, 'layer': 'locality'
{ }
'bool': { }
'must': [ }
{ },
'multi_match': { {
'query': 'neighbourhood value', 'bool': {
'type': 'phrase', 'must': [
'fields': [ {
'parent.localadmin', 'multi_match': {
'parent.localadmin_a' 'query': 'neighbourhood value',
] 'type': 'phrase',
} 'fields': [
} 'parent.localadmin',
], 'parent.localadmin_a'
'filter': { ]
'term': { }
'layer': 'localadmin' }
} ],
} 'filter': {
} 'term': {
}, 'layer': 'localadmin'
{ }
'bool': { }
'must': [ }
{ },
'multi_match': { {
'query': 'neighbourhood value', 'bool': {
'type': 'phrase', 'must': [
'fields': [ {
'parent.county', 'multi_match': {
'parent.county_a' 'query': 'neighbourhood value',
] 'type': 'phrase',
} 'fields': [
} 'parent.county',
], 'parent.county_a'
'filter': { ]
'term': { }
'layer': 'county' }
} ],
} 'filter': {
} 'term': {
}, 'layer': 'county'
{ }
'bool': { }
'must': [ }
{ },
'multi_match': { {
'query': 'neighbourhood value', 'bool': {
'type': 'phrase', 'must': [
'fields': [ {
'parent.macrocounty', 'multi_match': {
'parent.macrocounty_a' 'query': 'neighbourhood value',
] 'type': 'phrase',
} 'fields': [
} 'parent.macrocounty',
], 'parent.macrocounty_a'
'filter': { ]
'term': { }
'layer': 'macrocounty' }
} ],
} 'filter': {
} 'term': {
}, 'layer': 'macrocounty'
{ }
'bool': { }
'must': [ }
{ },
'multi_match': { {
'query': 'neighbourhood value', 'bool': {
'type': 'phrase', 'must': [
'fields': [ {
'parent.region', 'multi_match': {
'parent.region_a' 'query': 'neighbourhood value',
] 'type': 'phrase',
} 'fields': [
} 'parent.region',
], 'parent.region_a'
'filter': { ]
'term': { }
'layer': 'region' }
} ],
} 'filter': {
} 'term': {
}, 'layer': 'region'
{ }
'bool': { }
'must': [ }
{ },
'multi_match': { {
'query': 'neighbourhood value', 'bool': {
'type': 'phrase', 'must': [
'fields': [ {
'parent.macroregion', 'multi_match': {
'parent.macroregion_a' 'query': 'neighbourhood value',
] 'type': 'phrase',
} 'fields': [
} 'parent.macroregion',
], 'parent.macroregion_a'
'filter': { ]
'term': { }
'layer': 'macroregion' }
} ],
} 'filter': {
} 'term': {
}, 'layer': 'macroregion'
{ }
'bool': { }
'must': [ }
{ },
'multi_match': { {
'query': 'neighbourhood value', 'bool': {
'type': 'phrase', 'must': [
'fields': [ {
'parent.dependency', 'multi_match': {
'parent.dependency_a' 'query': 'neighbourhood value',
] 'type': 'phrase',
'fields': [
'parent.dependency',
'parent.dependency_a'
]
}
}
],
'filter': {
'term': {
'layer': 'dependency'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.country',
'parent.country_a'
]
}
}
],
'filter': {
'term': {
'layer': 'country'
}
}
}
} }
} ]
],
'filter': {
'term': {
'layer': 'dependency'
}
} }
} },
}, 'filter': {
{ 'bool': {
'bool': { 'must': []
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.country',
'parent.country_a'
]
}
}
],
'filter': {
'term': {
'layer': 'country'
}
} }
} }
}, }
},
'max_boost': 20,
'functions': [
{ {
'function_score': { 'field_value_factor': {
'query': null, 'modifier': 'log1p',
'max_boost': 20, 'field': 'popularity',
'functions': [ 'missing': 1
{ },
'field_value_factor': { 'weight': 1
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}
],
'score_mode': 'first',
'boost_mode': 'replace'
}
}, },
{ {
'function_score': { 'field_value_factor': {
'query': null, 'modifier': 'log1p',
'max_boost': 20, 'field': 'population',
'functions': [ 'missing': 1
{ },
'field_value_factor': { 'weight': 2
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}
],
'score_mode': 'first',
'boost_mode': 'replace'
}
} }
] ],
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, },
'size': 20, 'size': 20,

134
test/unit/fixture/search_linguistic_bbox.js

@ -1,98 +1,62 @@
module.exports = { module.exports = {
'query': { 'query': {
'bool': { 'function_score': {
'must': [{ 'query': {
'match': { 'filtered': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': { 'query': {
'match': { 'bool': {
'phrase.default': { 'should': []
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, },
'max_boost': 20, 'filter': {
'score_mode': 'first', 'bool': {
'boost_mode': 'replace', 'must': [
'functions': [{ {
'field_value_factor': { 'geo_bounding_box': {
'modifier': 'log1p', 'type': 'indexed',
'field': 'popularity', 'center_point': {
'missing': 1 'top': 11.51,
}, 'right': -61.84,
'weight': 1 'bottom': 47.47,
}] 'left': -103.16
} }
},{ }
'function_score': { },
'query': { {
'match': { 'terms': {
'phrase.default': { 'layer': [
'query': 'test', 'test'
'analyzer': 'peliasPhrase', ]
'type': 'phrase', }
'slop': 2, }
'boost': 1 ]
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter': [{
'geo_bounding_box': {
'type': 'indexed',
'center_point': {
'top': 11.51,
'right': -61.84,
'bottom': 47.47,
'left': -103.16
} }
} }
}
},
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}, },
{ {
'terms': { 'field_value_factor': {
'layer': [ 'modifier': 'log1p',
'test' 'field': 'population',
] 'missing': 1
} },
}] 'weight': 2
}
],
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, },
'sort': [ '_score' ],
'size': 10, 'size': 10,
'track_scores': true 'track_scores': true
}; };

98
test/unit/fixture/search_linguistic_bbox_original.js

@ -0,0 +1,98 @@
module.exports = {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter': [{
'geo_bounding_box': {
'type': 'indexed',
'center_point': {
'top': 11.51,
'right': -61.84,
'bottom': 47.47,
'left': -103.16
}
}
},
{
'terms': {
'layer': [
'test'
]
}
}]
}
},
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};

154
test/unit/fixture/search_linguistic_focus.js

@ -1,119 +1,65 @@
module.exports = { module.exports = {
'query': { 'query': {
'bool': { 'function_score': {
'must': [{ 'query': {
'match': { 'filtered': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
}, {
'function_score': {
'query': { 'query': {
'match': { 'bool': {
'phrase.default': { 'should': []
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
} }
}, },
'functions': [{ 'filter': {
'linear': { 'bool': {
'center_point': { 'must': [
'origin': { {
'lat': 29.49136, 'terms': {
'lon': -82.50622 'layer': [
}, 'test'
'offset': '0km', ]
'scale': '50km', }
'decay': 0.5 }
} ]
},
'weight': 2
}],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, }
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
} }
},{ },
'function_score': { 'max_boost': 20,
'query': { 'functions': [
'match': { {
'phrase.default': { 'weight': 2,
'query': 'test', 'linear': {
'analyzer': 'peliasPhrase', 'center_point': {
'type': 'phrase', 'origin': {
'slop': 2, 'lat': 29.49136,
'boost': 1 'lon': -82.50622
} },
'offset': '0km',
'scale': '50km',
'decay': 0.5
} }
}
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
}, },
'max_boost': 20, 'weight': 1
'score_mode': 'first', },
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter': [
{ {
'terms': { 'field_value_factor': {
'layer': [ 'modifier': 'log1p',
'test' 'field': 'population',
] 'missing': 1
} },
'weight': 2
} }
] ],
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, },
'sort': [ '_score' ],
'size': 10, 'size': 10,
'track_scores': true 'track_scores': true
}; };

174
test/unit/fixture/search_linguistic_focus_bbox.js

@ -1,128 +1,76 @@
module.exports = { module.exports = {
'query': { 'query': {
'bool': { 'function_score': {
'must': [{ 'query': {
'match': { 'filtered': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
}, {
'function_score': {
'query': { 'query': {
'match': { 'bool': {
'phrase.default': { 'should': []
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
} }
}, },
'functions': [{ 'filter': {
'linear': { 'bool': {
'center_point': { 'must': [
'origin': { {
'lat': 29.49136, 'geo_bounding_box': {
'lon': -82.50622 'type': 'indexed',
'center_point': {
'top': 11.51,
'right': -61.84,
'bottom': 47.47,
'left': -103.16
}
}
}, },
'offset': '0km', {
'scale': '50km', 'terms': {
'decay': 0.5 'layer': [
} 'test'
}, ]
'weight': 2 }
}], }
'score_mode': 'avg', ]
'boost_mode': 'replace'
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter': [{
'geo_bounding_box': {
'type': 'indexed',
'center_point': {
'top': 11.51,
'right': -61.84,
'bottom': 47.47,
'left': -103.16
} }
} }
}, },
{ 'max_boost': 20,
'terms': { 'functions': [
'layer': [ {
'test' 'weight': 2,
] 'linear': {
'center_point': {
'origin': {
'lat': 29.49136,
'lon': -82.50622
},
'offset': '0km',
'scale': '50km',
'decay': 0.5
}
}
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
} }
}] ],
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, },
'sort': [ '_score' ],
'size': 10, 'size': 10,
'track_scores': true 'track_scores': true
}; };

128
test/unit/fixture/search_linguistic_focus_bbox_original.js

@ -0,0 +1,128 @@
module.exports = {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
}, {
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
'functions': [{
'linear': {
'center_point': {
'origin': {
'lat': 29.49136,
'lon': -82.50622
},
'offset': '0km',
'scale': '50km',
'decay': 0.5
}
},
'weight': 2
}],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter': [{
'geo_bounding_box': {
'type': 'indexed',
'center_point': {
'top': 11.51,
'right': -61.84,
'bottom': 47.47,
'left': -103.16
}
}
},
{
'terms': {
'layer': [
'test'
]
}
}]
}
},
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};

154
test/unit/fixture/search_linguistic_focus_null_island.js

@ -1,117 +1,65 @@
module.exports = { module.exports = {
'query': { 'query': {
'bool': { 'function_score': {
'must': [{ 'query': {
'match': { 'filtered': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
}, {
'function_score': {
'query': { 'query': {
'match': { 'bool': {
'phrase.default': { 'should': []
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
} }
}, },
'functions': [{ 'filter': {
'linear': { 'bool': {
'center_point': { 'must': [
'origin': { {
'lat': 0, 'terms': {
'lon': 0 'layer': [
}, 'test'
'offset': '0km', ]
'scale': '50km', }
'decay': 0.5 }
} ]
},
'weight': 2
}],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, }
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
} }
},{ },
'function_score': { 'max_boost': 20,
'query': { 'functions': [
'match': { {
'phrase.default': { 'weight': 2,
'query': 'test', 'linear': {
'analyzer': 'peliasPhrase', 'center_point': {
'type': 'phrase', 'origin': {
'slop': 2, 'lat': 0,
'boost': 1 'lon': 0
} },
'offset': '0km',
'scale': '50km',
'decay': 0.5
} }
}
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
}, },
'max_boost': 20, 'weight': 1
'score_mode': 'first', },
'boost_mode': 'replace', {
'functions': [{ 'field_value_factor': {
'field_value_factor': { 'modifier': 'log1p',
'modifier': 'log1p', 'field': 'population',
'field': 'population', 'missing': 1
'missing': 1 },
}, 'weight': 2
'weight': 2
}]
}
}],
'filter':[{
'terms': {
'layer': [
'test'
]
} }
}] ],
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, },
'sort': [ '_score' ],
'size': 10, 'size': 10,
'track_scores': true 'track_scores': true
}; };

117
test/unit/fixture/search_linguistic_focus_null_island_original.js

@ -0,0 +1,117 @@
module.exports = {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
}, {
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
'functions': [{
'linear': {
'center_point': {
'origin': {
'lat': 0,
'lon': 0
},
'offset': '0km',
'scale': '50km',
'decay': 0.5
}
},
'weight': 2
}],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter':[{
'terms': {
'layer': [
'test'
]
}
}]
}
},
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};

119
test/unit/fixture/search_linguistic_focus_original.js

@ -0,0 +1,119 @@
module.exports = {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
}, {
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
'functions': [{
'linear': {
'center_point': {
'origin': {
'lat': 29.49136,
'lon': -82.50622
},
'offset': '0km',
'scale': '50km',
'decay': 0.5
}
},
'weight': 2
}],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter': [
{
'terms': {
'layer': [
'test'
]
}
}
]
}
},
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};

114
test/unit/fixture/search_linguistic_only.js

@ -1,89 +1,51 @@
module.exports = { module.exports = {
'query': { 'query': {
'bool': { 'function_score': {
'must': [{ 'query': {
'match': { 'filtered': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': { 'query': {
'match': { 'bool': {
'phrase.default': { 'should': []
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, },
'max_boost': 20, 'filter': {
'score_mode': 'first', 'bool': {
'boost_mode': 'replace', 'must': [
'functions': [{ {
'field_value_factor': { 'terms': {
'modifier': 'log1p', 'layer': [
'field': 'popularity', 'test'
'missing': 1 ]
}, }
'weight': 1 }
}] ]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, }
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
} }
}], },
'filter': [ 'max_boost': 20,
'functions': [
{ {
'terms': { 'field_value_factor': {
'layer': [ 'modifier': 'log1p',
'test' 'field': 'popularity',
] 'missing': 1
} },
'weight': 1
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
} }
] ],
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, },
'sort': [ '_score' ],
'size': 10, 'size': 10,
'track_scores': true 'track_scores': true
}; };

89
test/unit/fixture/search_linguistic_only_original.js

@ -0,0 +1,89 @@
module.exports = {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter': [
{
'terms': {
'layer': [
'test'
]
}
}
]
}
},
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};

156
test/unit/fixture/search_linguistic_viewport.js

@ -1,133 +1,51 @@
module.exports = { module.exports = {
'query': { 'query': {
'bool': { 'function_score': {
'must': [ 'query': {
{ 'filtered': {
'match': { 'query': {
'name.default': { 'bool': {
'analyzer': 'peliasQueryFullToken', 'should': []
'boost': 1,
'query': 'test'
}
}
}
],
'should': [
{
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
} }
} },
}, 'filter': {
{ 'bool': {
'function_score': { 'must': [
'query': { {
'match': { 'terms': {
'phrase.default': { 'layer': [
'analyzer': 'peliasPhrase', 'test'
'type': 'phrase', ]
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
'functions': [
{
'weight': 2,
'linear': {
'center_point': {
'origin': {
'lat': 29.49136,
'lon': -82.50622
},
'offset': '0km',
'scale': '50km',
'decay': 0.5
} }
} }
} ]
], }
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, }
},
'max_boost': 20,
'functions': [
{ {
'function_score': { 'field_value_factor': {
'query': { 'modifier': 'log1p',
'match': { 'field': 'popularity',
'phrase.default': { 'missing': 1
'analyzer': 'peliasPhrase', },
'type': 'phrase', 'weight': 1
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}
],
'score_mode': 'first',
'boost_mode': 'replace'
}
}, },
{ {
'function_score': { 'field_value_factor': {
'query': { 'modifier': 'log1p',
'match': { 'field': 'population',
'phrase.default': { 'missing': 1
'analyzer': 'peliasPhrase', },
'type': 'phrase', 'weight': 2
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}
],
'score_mode': 'first',
'boost_mode': 'replace'
}
} }
], ],
'filter': [ 'score_mode': 'avg',
{ 'boost_mode': 'replace'
'terms': {
'layer': [
'test'
]
}
}
]
} }
}, },
'size': 10, 'size': 10,
'track_scores': true, 'track_scores': true
'sort': [ };
'_score'
]
};

159
test/unit/fixture/search_linguistic_viewport_min_diagonal.js

@ -1,128 +1,51 @@
module.exports = { module.exports = {
'query': { 'query': {
'filtered': { 'function_score': {
'query': { 'query': {
'bool': { 'filtered': {
'must': [ 'query': {
{ 'bool': {
'match': { 'should': []
'name.default': {
'analyzer': 'peliasQueryFullToken',
'boost': 1,
'query': 'test'
}
}
} }
], },
'should': [ 'filter': {
{ 'bool': {
'match': { 'must': [
'phrase.default': { {
'analyzer': 'peliasPhrase', 'terms': {
'type': 'phrase', 'layer': [
'boost': 1, 'test'
'slop': 2, ]
'query': 'test'
}
}
},
{
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
'functions': [
{
'weight': 2,
'linear': {
'center_point': {
'origin': {
'lat': 28.49136,
'lon': -87.50623
},
'offset': '0km',
'scale': '1km',
'decay': 0.5
}
}
}
],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},
{
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
} }
], }
'score_mode': 'first', ]
'boost_mode': 'replace'
}
},
{
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}
],
'score_mode': 'first',
'boost_mode': 'replace'
}
} }
] }
}
},
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
} }
} ],
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, },
'size': 10, 'size': 10,
'track_scores': true, 'track_scores': true
'sort': [ };
'_score'
]
};

0
test/unit/fixture/search_partial_address.js → test/unit/fixture/search_partial_address_original.js

0
test/unit/fixture/search_regions_address.js → test/unit/fixture/search_regions_address_original.js

116
test/unit/fixture/search_with_category_filtering.js

@ -1,86 +1,52 @@
module.exports = { module.exports = {
'query': { 'query': {
'bool': { 'function_score': {
'must': [{ 'query': {
'match': { 'filtered': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
}, {
'function_score': {
'query': { 'query': {
'match': { 'bool': {
'phrase.default': { 'should': []
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, },
'max_boost': 20, 'filter': {
'score_mode': 'first', 'bool': {
'boost_mode': 'replace', 'must': [
'functions': [{ {
'field_value_factor': { 'terms': {
'modifier': 'log1p', 'category': [
'field': 'popularity', 'retail',
'missing': 1 'food'
}, ]
'weight': 1 }
}] }
} ]
}, {
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, }
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
} }
}], },
'filter': [{ 'max_boost': 20,
'terms': { 'functions': [
'category': ['retail', 'food'] {
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
} }
}] ],
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, },
'size': 20, 'size': 20,
'track_scores': true, 'track_scores': true
'sort': [ };
'_score'
]
};

86
test/unit/fixture/search_with_category_filtering_original.js

@ -0,0 +1,86 @@
module.exports = {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
}, {
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
}
}, {
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter': [{
'terms': {
'category': ['retail', 'food']
}
}]
}
},
'size': 20,
'track_scores': true,
'sort': [
'_score'
]
};

112
test/unit/fixture/search_with_source_filtering.js

@ -1,85 +1,51 @@
module.exports = { module.exports = {
'query': { 'query': {
'bool': { 'function_score': {
'must': [{ 'query': {
'match': { 'filtered': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': { 'query': {
'match': { 'bool': {
'phrase.default': { 'should': []
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, },
'max_boost': 20, 'filter': {
'score_mode': 'first', 'bool': {
'boost_mode': 'replace', 'must': [
'functions': [{ {
'field_value_factor': { 'terms': {
'modifier': 'log1p', 'source': [
'field': 'popularity', 'test_source'
'missing': 1 ]
}, }
'weight': 1 }
}] ]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
} }
}, }
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
} }
}], },
'filter': [{ 'max_boost': 20,
'terms': { 'functions': [
'source': ['test_source'] {
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
} }
}] ],
'score_mode': 'avg',
'boost_mode': 'replace'
} }
}, },
'sort': [ '_score' ],
'size': 20, 'size': 20,
'track_scores': true 'track_scores': true
}; };

85
test/unit/fixture/search_with_source_filtering_original.js

@ -0,0 +1,85 @@
module.exports = {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}],
'filter': [{
'terms': {
'source': ['test_source']
}
}]
}
},
'sort': [ '_score' ],
'size': 20,
'track_scores': true
};

295
test/unit/query/search.js

@ -1,4 +1,5 @@
var generate = require('../../../query/search'); var generate = require('../../../query/search');
var fs = require('fs');
module.exports.tests = {}; module.exports.tests = {};
@ -10,117 +11,117 @@ module.exports.tests.interface = function(test, common) {
}; };
module.exports.tests.query = function(test, common) { module.exports.tests.query = function(test, common) {
// test('valid search + focus + bbox', function(t) { test('valid search + focus + bbox', function(t) {
// var query = generate({ var query = generate({
// text: 'test', querySize: 10, text: 'test', querySize: 10,
// 'focus.point.lat': 29.49136, 'focus.point.lon': -82.50622, 'focus.point.lat': 29.49136, 'focus.point.lon': -82.50622,
// 'boundary.rect.min_lat': 47.47, 'boundary.rect.min_lat': 47.47,
// 'boundary.rect.max_lon': -61.84, 'boundary.rect.max_lon': -61.84,
// 'boundary.rect.max_lat': 11.51, 'boundary.rect.max_lat': 11.51,
// 'boundary.rect.min_lon': -103.16, 'boundary.rect.min_lon': -103.16,
// layers: ['test'] layers: ['test']
// }); });
//
// var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_focus_bbox'); var expected = require('../fixture/search_linguistic_focus_bbox');
//
// t.deepEqual(compiled, expected, 'search_linguistic_focus_bbox'); t.deepEqual(compiled, expected, 'search_linguistic_focus_bbox');
// t.end(); t.end();
// }); });
// test('valid search + bbox', function(t) { test('valid search + bbox', function(t) {
// var query = generate({ var query = generate({
// text: 'test', querySize: 10, text: 'test', querySize: 10,
// 'boundary.rect.min_lat': 47.47, 'boundary.rect.min_lat': 47.47,
// 'boundary.rect.max_lon': -61.84, 'boundary.rect.max_lon': -61.84,
// 'boundary.rect.max_lat': 11.51, 'boundary.rect.max_lat': 11.51,
// 'boundary.rect.min_lon': -103.16, 'boundary.rect.min_lon': -103.16,
// layers: ['test'] layers: ['test']
// }); });
//
// var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_bbox'); var expected = require('../fixture/search_linguistic_bbox');
//
// t.deepEqual(compiled, expected, 'search_linguistic_bbox'); t.deepEqual(compiled, expected, 'search_linguistic_bbox');
// t.end(); t.end();
// }); });
// test('valid lingustic-only search', function(t) { test('valid lingustic-only search', function(t) {
// var query = generate({ var query = generate({
// text: 'test', querySize: 10, text: 'test', querySize: 10,
// layers: ['test'] layers: ['test']
// }); });
//
// var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_only'); var expected = require('../fixture/search_linguistic_only');
//
// t.deepEqual(compiled, expected, 'search_linguistic_only'); t.deepEqual(compiled, expected, 'search_linguistic_only');
// t.end(); t.end();
// }); });
// test('search search + focus', function(t) { test('search search + focus', function(t) {
// var query = generate({ var query = generate({
// text: 'test', querySize: 10, text: 'test', querySize: 10,
// 'focus.point.lat': 29.49136, 'focus.point.lon': -82.50622, 'focus.point.lat': 29.49136, 'focus.point.lon': -82.50622,
// layers: ['test'] layers: ['test']
// }); });
//
// var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_focus'); var expected = require('../fixture/search_linguistic_focus');
//
// t.deepEqual(compiled, expected, 'search_linguistic_focus'); t.deepEqual(compiled, expected, 'search_linguistic_focus');
// t.end(); t.end();
// }); });
// test('search search + viewport', function(t) { test('search search + viewport', function(t) {
// var query = generate({ var query = generate({
// text: 'test', querySize: 10, text: 'test', querySize: 10,
// 'focus.viewport.min_lat': 28.49136, 'focus.viewport.min_lat': 28.49136,
// 'focus.viewport.max_lat': 30.49136, 'focus.viewport.max_lat': 30.49136,
// 'focus.viewport.min_lon': -87.50622, 'focus.viewport.min_lon': -87.50622,
// 'focus.viewport.max_lon': -77.50622, 'focus.viewport.max_lon': -77.50622,
// layers: ['test'] layers: ['test']
// }); });
//
// var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_viewport'); var expected = require('../fixture/search_linguistic_viewport');
//
// t.deepEqual(compiled, expected, 'search_linguistic_viewport'); t.deepEqual(compiled, expected, 'search_linguistic_viewport');
// t.end(); t.end();
// }); });
// viewport scale sizing currently disabled. // viewport scale sizing currently disabled.
// ref: https://github.com/pelias/api/pull/388 // ref: https://github.com/pelias/api/pull/388
// test('search with viewport diagonal < 1km should set scale to 1km', function(t) { test('search with viewport diagonal < 1km should set scale to 1km', function(t) {
// var query = generate({ var query = generate({
// text: 'test', querySize: 10, text: 'test', querySize: 10,
// 'focus.viewport.min_lat': 28.49135, 'focus.viewport.min_lat': 28.49135,
// 'focus.viewport.max_lat': 28.49137, 'focus.viewport.max_lat': 28.49137,
// 'focus.viewport.min_lon': -87.50622, 'focus.viewport.min_lon': -87.50622,
// 'focus.viewport.max_lon': -87.50624, 'focus.viewport.max_lon': -87.50624,
// layers: ['test'] layers: ['test']
// }); });
//
// var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_viewport_min_diagonal'); var expected = require('../fixture/search_linguistic_viewport_min_diagonal');
//
// t.deepEqual(compiled, expected, 'valid search query'); t.deepEqual(compiled, expected, 'valid search query');
// t.end(); t.end();
// }); });
// test('search search + focus on null island', function(t) { test('search search + focus on null island', function(t) {
// var query = generate({ var query = generate({
// text: 'test', querySize: 10, text: 'test', querySize: 10,
// 'focus.point.lat': 0, 'focus.point.lon': 0, 'focus.point.lat': 0, 'focus.point.lon': 0,
// layers: ['test'] layers: ['test']
// }); });
//
// var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_focus_null_island'); var expected = require('../fixture/search_linguistic_focus_null_island');
//
// t.deepEqual(compiled, expected, 'search_linguistic_focus_null_island'); t.deepEqual(compiled, expected, 'search_linguistic_focus_null_island');
// t.end(); t.end();
// }); });
test('parsed_text with all fields should use FallbackQuery', function(t) { test('parsed_text with all fields should use FallbackQuery', function(t) {
var clean = { var clean = {
@ -166,45 +167,45 @@ module.exports.tests.query = function(test, common) {
}); });
// test('valid boundary.country search', function(t) { test('valid boundary.country search', function(t) {
// var query = generate({ var query = generate({
// text: 'test', querySize: 10, text: 'test', querySize: 10,
// layers: ['test'], layers: ['test'],
// 'boundary.country': 'ABC' 'boundary.country': 'ABC'
// }); });
//
// var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_boundary_country'); var expected = require('../fixture/search_boundary_country');
//
// t.deepEqual(compiled, expected, 'search: valid boundary.country query'); t.deepEqual(compiled, expected, 'search: valid boundary.country query');
// t.end(); t.end();
// }); });
// test('valid sources filter', function(t) { test('valid sources filter', function(t) {
// var query = generate({ var query = generate({
// 'text': 'test', 'text': 'test',
// 'sources': ['test_source'] 'sources': ['test_source']
// }); });
//
// var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_with_source_filtering'); var expected = require('../fixture/search_with_source_filtering');
//
// t.deepEqual(compiled, expected, 'search: valid search query with source filtering'); t.deepEqual(compiled, expected, 'search: valid search query with source filtering');
// t.end(); t.end();
// }); });
//test('categories filter', function(t) { test('categories filter', function(t) {
//var query = generate({ var query = generate({
//'text': 'test', 'text': 'test',
//'categories': ['retail','food'] 'categories': ['retail','food']
//}); });
//var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
//var expected = require('../fixture/search_with_category_filtering'); var expected = require('../fixture/search_with_category_filtering');
//t.deepEqual(compiled, expected, 'valid search query with category filtering'); t.deepEqual(compiled, expected, 'valid search query with category filtering');
//t.end(); t.end();
//}); });
}; };
module.exports.all = function (tape, common) { module.exports.all = function (tape, common) {

22
test/unit/query/search_original.js

@ -22,7 +22,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_bbox'); var expected = require('../fixture/search_linguistic_focus_bbox_original');
t.deepEqual(compiled, expected, 'search_linguistic_focus_bbox'); t.deepEqual(compiled, expected, 'search_linguistic_focus_bbox');
t.end(); t.end();
@ -39,7 +39,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_bbox'); var expected = require('../fixture/search_linguistic_bbox_original');
t.deepEqual(compiled, expected, 'search_linguistic_bbox'); t.deepEqual(compiled, expected, 'search_linguistic_bbox');
t.end(); t.end();
@ -52,7 +52,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_only'); var expected = require('../fixture/search_linguistic_only_original');
t.deepEqual(compiled, expected, 'search_linguistic_only'); t.deepEqual(compiled, expected, 'search_linguistic_only');
t.end(); t.end();
@ -66,7 +66,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus'); var expected = require('../fixture/search_linguistic_focus_original');
t.deepEqual(compiled, expected, 'search_linguistic_focus'); t.deepEqual(compiled, expected, 'search_linguistic_focus');
t.end(); t.end();
@ -80,7 +80,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_null_island'); var expected = require('../fixture/search_linguistic_focus_null_island_original');
t.deepEqual(compiled, expected, 'search_linguistic_focus_null_island'); t.deepEqual(compiled, expected, 'search_linguistic_focus_null_island');
t.end(); t.end();
@ -101,7 +101,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_full_address'); var expected = require('../fixture/search_full_address_original');
t.deepEqual(compiled, expected, 'search_full_address'); t.deepEqual(compiled, expected, 'search_full_address');
t.end(); t.end();
@ -119,7 +119,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_partial_address'); var expected = require('../fixture/search_partial_address_original');
t.deepEqual(compiled, expected, 'search_partial_address'); t.deepEqual(compiled, expected, 'search_partial_address');
t.end(); t.end();
@ -137,7 +137,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_regions_address'); var expected = require('../fixture/search_regions_address_original');
t.deepEqual(compiled, expected, 'search_regions_address'); t.deepEqual(compiled, expected, 'search_regions_address');
t.end(); t.end();
@ -151,7 +151,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_boundary_country'); var expected = require('../fixture/search_boundary_country_original');
t.deepEqual(compiled, expected, 'search: valid boundary.country query'); t.deepEqual(compiled, expected, 'search: valid boundary.country query');
t.end(); t.end();
@ -164,7 +164,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_with_source_filtering'); var expected = require('../fixture/search_with_source_filtering_original');
t.deepEqual(compiled, expected, 'search: valid search query with source filtering'); t.deepEqual(compiled, expected, 'search: valid search query with source filtering');
t.end(); t.end();
@ -177,7 +177,7 @@ module.exports.tests.query = function(test, common) {
}); });
var compiled = JSON.parse( JSON.stringify( query ) ); var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_with_category_filtering'); var expected = require('../fixture/search_with_category_filtering_original');
t.deepEqual(compiled, expected, 'valid search query with category filtering'); t.deepEqual(compiled, expected, 'valid search query with category filtering');
t.end(); t.end();

Loading…
Cancel
Save