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-logger": "0.0.8",
"pelias-model": "4.2.0",
"pelias-query": "8.5.0",
"pelias-query": "pelias/query#f890a72",
"pelias-text-analyzer": "1.3.0",
"stats-lite": "2.0.3",
"through2": "2.0.1"

53
query/search.js

@ -7,43 +7,32 @@ var peliasQuery = require('pelias-query'),
// general-purpose search query
//------------------------------
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();
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
// query.score( peliasQuery.view.phrase );
// query.score( peliasQuery.view.focus( peliasQuery.view.phrase ) );
// query.score( peliasQuery.view.popularity( peliasQuery.view.phrase ) );
// query.score( peliasQuery.view.population( peliasQuery.view.phrase ) );
// address components
// query.score( peliasQuery.view.address('housenumber'), 'must' );
// 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') );
fallbackQuery.score( peliasQuery.view.focus_only_function( peliasQuery.view.phrase ) );
fallbackQuery.score( peliasQuery.view.popularity_only_function );
fallbackQuery.score( peliasQuery.view.population_only_function );
geodisambiguationQuery.score( peliasQuery.view.focus_only_function( peliasQuery.view.phrase ) );
geodisambiguationQuery.score( peliasQuery.view.popularity_only_function );
geodisambiguationQuery.score( peliasQuery.view.population_only_function );
// --------------------------------
// non-scoring hard filters
// query.filter( peliasQuery.view.boundary_circle );
// query.filter( peliasQuery.view.boundary_rect );
// query.filter( peliasQuery.view.sources );
// query.filter( peliasQuery.view.layers );
// query.filter( peliasQuery.view.categories );
fallbackQuery.filter( peliasQuery.view.boundary_country );
fallbackQuery.filter( peliasQuery.view.boundary_circle );
fallbackQuery.filter( peliasQuery.view.boundary_rect );
fallbackQuery.filter( peliasQuery.view.sources );
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 = {
'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': {
'function_score': {
'query': {
'filtered': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
'bool': {
'should': []
}
},
'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
}
'filter': {
'bool': {
'must': [
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
}
},
{
'terms': {
'layer': [
'test'
]
}
}
]
}
},
'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': {
'layer': [
'test'
]
}
'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,
'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 = {
'query': {
'bool': {
'should': [
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.neighbourhood',
'parent.neighbourhood_a'
]
}
}
],
'filter': {
'term': {
'layer': 'neighbourhood'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.borough',
'parent.borough_a'
]
}
}
],
'filter': {
'term': {
'layer': 'borough'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.locality',
'parent.locality_a'
]
}
}
],
'filter': {
'term': {
'layer': 'locality'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.localadmin',
'parent.localadmin_a'
]
}
}
],
'filter': {
'term': {
'layer': 'localadmin'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.county',
'parent.county_a'
]
}
}
],
'filter': {
'term': {
'layer': 'county'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.macrocounty',
'parent.macrocounty_a'
]
}
}
],
'filter': {
'term': {
'layer': 'macrocounty'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.region',
'parent.region_a'
]
}
}
],
'filter': {
'term': {
'layer': 'region'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.macroregion',
'parent.macroregion_a'
]
}
}
],
'filter': {
'term': {
'layer': 'macroregion'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.dependency',
'parent.dependency_a'
]
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'should': [
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.neighbourhood',
'parent.neighbourhood_a'
]
}
}
],
'filter': {
'term': {
'layer': 'neighbourhood'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.borough',
'parent.borough_a'
]
}
}
],
'filter': {
'term': {
'layer': 'borough'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.locality',
'parent.locality_a'
]
}
}
],
'filter': {
'term': {
'layer': 'locality'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.localadmin',
'parent.localadmin_a'
]
}
}
],
'filter': {
'term': {
'layer': 'localadmin'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.county',
'parent.county_a'
]
}
}
],
'filter': {
'term': {
'layer': 'county'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.macrocounty',
'parent.macrocounty_a'
]
}
}
],
'filter': {
'term': {
'layer': 'macrocounty'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.region',
'parent.region_a'
]
}
}
],
'filter': {
'term': {
'layer': 'region'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.macroregion',
'parent.macroregion_a'
]
}
}
],
'filter': {
'term': {
'layer': 'macroregion'
}
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'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'
}
]
}
}
},
{
'bool': {
'must': [
{
'multi_match': {
'query': 'neighbourhood value',
'type': 'phrase',
'fields': [
'parent.country',
'parent.country_a'
]
}
}
],
'filter': {
'term': {
'layer': 'country'
}
},
'filter': {
'bool': {
'must': []
}
}
},
}
},
'max_boost': 20,
'functions': [
{
'function_score': {
'query': null,
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}
],
'score_mode': 'first',
'boost_mode': 'replace'
}
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
},
{
'function_score': {
'query': null,
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}
],
'score_mode': 'first',
'boost_mode': 'replace'
}
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}
]
],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},
'size': 20,

134
test/unit/fixture/search_linguistic_bbox.js

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

174
test/unit/fixture/search_linguistic_focus_bbox.js

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

159
test/unit/fixture/search_linguistic_viewport_min_diagonal.js

@ -1,128 +1,51 @@
module.exports = {
'query': {
'filtered': {
'function_score': {
'query': {
'bool': {
'must': [
{
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'boost': 1,
'query': 'test'
}
}
'filtered': {
'query': {
'bool': {
'should': []
}
],
'should': [
{
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'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
},
'filter': {
'bool': {
'must': [
{
'terms': {
'layer': [
'test'
]
}
],
'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,
'track_scores': true,
'sort': [
'_score'
]
};
'track_scores': true
};

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 = {
'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': {
'function_score': {
'query': {
'filtered': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
'bool': {
'should': []
}
},
'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
}
'filter': {
'bool': {
'must': [
{
'terms': {
'category': [
'retail',
'food'
]
}
}
]
}
},
'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']
},
'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': 20,
'track_scores': true,
'sort': [
'_score'
]
};
'track_scores': true
};

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 = {
'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': {
'function_score': {
'query': {
'filtered': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
'bool': {
'should': []
}
},
'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
}
'filter': {
'bool': {
'must': [
{
'terms': {
'source': [
'test_source'
]
}
}
]
}
},
'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']
},
'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'
}
},
'sort': [ '_score' ],
'size': 20,
'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 fs = require('fs');
module.exports.tests = {};
@ -10,117 +11,117 @@ module.exports.tests.interface = function(test, common) {
};
module.exports.tests.query = function(test, common) {
// test('valid search + focus + bbox', function(t) {
// var query = generate({
// text: 'test', querySize: 10,
// 'focus.point.lat': 29.49136, 'focus.point.lon': -82.50622,
// 'boundary.rect.min_lat': 47.47,
// 'boundary.rect.max_lon': -61.84,
// 'boundary.rect.max_lat': 11.51,
// 'boundary.rect.min_lon': -103.16,
// layers: ['test']
// });
//
// var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_focus_bbox');
//
// t.deepEqual(compiled, expected, 'search_linguistic_focus_bbox');
// t.end();
// });
// test('valid search + bbox', function(t) {
// var query = generate({
// text: 'test', querySize: 10,
// 'boundary.rect.min_lat': 47.47,
// 'boundary.rect.max_lon': -61.84,
// 'boundary.rect.max_lat': 11.51,
// 'boundary.rect.min_lon': -103.16,
// layers: ['test']
// });
//
// var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_bbox');
//
// t.deepEqual(compiled, expected, 'search_linguistic_bbox');
// t.end();
// });
// test('valid lingustic-only search', function(t) {
// var query = generate({
// text: 'test', querySize: 10,
// layers: ['test']
// });
//
// var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_only');
//
// t.deepEqual(compiled, expected, 'search_linguistic_only');
// t.end();
// });
// test('search search + focus', function(t) {
// var query = generate({
// text: 'test', querySize: 10,
// 'focus.point.lat': 29.49136, 'focus.point.lon': -82.50622,
// layers: ['test']
// });
//
// var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_focus');
//
// t.deepEqual(compiled, expected, 'search_linguistic_focus');
// t.end();
// });
// test('search search + viewport', function(t) {
// var query = generate({
// text: 'test', querySize: 10,
// 'focus.viewport.min_lat': 28.49136,
// 'focus.viewport.max_lat': 30.49136,
// 'focus.viewport.min_lon': -87.50622,
// 'focus.viewport.max_lon': -77.50622,
// layers: ['test']
// });
//
// var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_viewport');
//
// t.deepEqual(compiled, expected, 'search_linguistic_viewport');
// t.end();
// });
test('valid search + focus + bbox', function(t) {
var query = generate({
text: 'test', querySize: 10,
'focus.point.lat': 29.49136, 'focus.point.lon': -82.50622,
'boundary.rect.min_lat': 47.47,
'boundary.rect.max_lon': -61.84,
'boundary.rect.max_lat': 11.51,
'boundary.rect.min_lon': -103.16,
layers: ['test']
});
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_bbox');
t.deepEqual(compiled, expected, 'search_linguistic_focus_bbox');
t.end();
});
test('valid search + bbox', function(t) {
var query = generate({
text: 'test', querySize: 10,
'boundary.rect.min_lat': 47.47,
'boundary.rect.max_lon': -61.84,
'boundary.rect.max_lat': 11.51,
'boundary.rect.min_lon': -103.16,
layers: ['test']
});
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_bbox');
t.deepEqual(compiled, expected, 'search_linguistic_bbox');
t.end();
});
test('valid lingustic-only search', function(t) {
var query = generate({
text: 'test', querySize: 10,
layers: ['test']
});
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_only');
t.deepEqual(compiled, expected, 'search_linguistic_only');
t.end();
});
test('search search + focus', function(t) {
var query = generate({
text: 'test', querySize: 10,
'focus.point.lat': 29.49136, 'focus.point.lon': -82.50622,
layers: ['test']
});
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus');
t.deepEqual(compiled, expected, 'search_linguistic_focus');
t.end();
});
test('search search + viewport', function(t) {
var query = generate({
text: 'test', querySize: 10,
'focus.viewport.min_lat': 28.49136,
'focus.viewport.max_lat': 30.49136,
'focus.viewport.min_lon': -87.50622,
'focus.viewport.max_lon': -77.50622,
layers: ['test']
});
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_viewport');
t.deepEqual(compiled, expected, 'search_linguistic_viewport');
t.end();
});
// viewport scale sizing currently disabled.
// ref: https://github.com/pelias/api/pull/388
// test('search with viewport diagonal < 1km should set scale to 1km', function(t) {
// var query = generate({
// text: 'test', querySize: 10,
// 'focus.viewport.min_lat': 28.49135,
// 'focus.viewport.max_lat': 28.49137,
// 'focus.viewport.min_lon': -87.50622,
// 'focus.viewport.max_lon': -87.50624,
// layers: ['test']
// });
//
// var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_viewport_min_diagonal');
//
// t.deepEqual(compiled, expected, 'valid search query');
// t.end();
// });
// test('search search + focus on null island', function(t) {
// var query = generate({
// text: 'test', querySize: 10,
// 'focus.point.lat': 0, 'focus.point.lon': 0,
// layers: ['test']
// });
//
// var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_linguistic_focus_null_island');
//
// t.deepEqual(compiled, expected, 'search_linguistic_focus_null_island');
// t.end();
// });
test('search with viewport diagonal < 1km should set scale to 1km', function(t) {
var query = generate({
text: 'test', querySize: 10,
'focus.viewport.min_lat': 28.49135,
'focus.viewport.max_lat': 28.49137,
'focus.viewport.min_lon': -87.50622,
'focus.viewport.max_lon': -87.50624,
layers: ['test']
});
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_viewport_min_diagonal');
t.deepEqual(compiled, expected, 'valid search query');
t.end();
});
test('search search + focus on null island', function(t) {
var query = generate({
text: 'test', querySize: 10,
'focus.point.lat': 0, 'focus.point.lon': 0,
layers: ['test']
});
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_linguistic_focus_null_island');
t.deepEqual(compiled, expected, 'search_linguistic_focus_null_island');
t.end();
});
test('parsed_text with all fields should use FallbackQuery', function(t) {
var clean = {
@ -166,45 +167,45 @@ module.exports.tests.query = function(test, common) {
});
// test('valid boundary.country search', function(t) {
// var query = generate({
// text: 'test', querySize: 10,
// layers: ['test'],
// 'boundary.country': 'ABC'
// });
//
// var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_boundary_country');
//
// t.deepEqual(compiled, expected, 'search: valid boundary.country query');
// t.end();
// });
// test('valid sources filter', function(t) {
// var query = generate({
// 'text': 'test',
// 'sources': ['test_source']
// });
//
// var compiled = JSON.parse( JSON.stringify( query ) );
// var expected = require('../fixture/search_with_source_filtering');
//
// t.deepEqual(compiled, expected, 'search: valid search query with source filtering');
// t.end();
// });
//test('categories filter', function(t) {
//var query = generate({
//'text': 'test',
//'categories': ['retail','food']
//});
//var compiled = JSON.parse( JSON.stringify( query ) );
//var expected = require('../fixture/search_with_category_filtering');
//t.deepEqual(compiled, expected, 'valid search query with category filtering');
//t.end();
//});
test('valid boundary.country search', function(t) {
var query = generate({
text: 'test', querySize: 10,
layers: ['test'],
'boundary.country': 'ABC'
});
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_boundary_country');
t.deepEqual(compiled, expected, 'search: valid boundary.country query');
t.end();
});
test('valid sources filter', function(t) {
var query = generate({
'text': 'test',
'sources': ['test_source']
});
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_with_source_filtering');
t.deepEqual(compiled, expected, 'search: valid search query with source filtering');
t.end();
});
test('categories filter', function(t) {
var query = generate({
'text': 'test',
'categories': ['retail','food']
});
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_with_category_filtering');
t.deepEqual(compiled, expected, 'valid search query with category filtering');
t.end();
});
};
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 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.end();
@ -39,7 +39,7 @@ module.exports.tests.query = function(test, common) {
});
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.end();
@ -52,7 +52,7 @@ module.exports.tests.query = function(test, common) {
});
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.end();
@ -66,7 +66,7 @@ module.exports.tests.query = function(test, common) {
});
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.end();
@ -80,7 +80,7 @@ module.exports.tests.query = function(test, common) {
});
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.end();
@ -101,7 +101,7 @@ module.exports.tests.query = function(test, common) {
});
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.end();
@ -119,7 +119,7 @@ module.exports.tests.query = function(test, common) {
});
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.end();
@ -137,7 +137,7 @@ module.exports.tests.query = function(test, common) {
});
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.end();
@ -151,7 +151,7 @@ module.exports.tests.query = function(test, common) {
});
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.end();
@ -164,7 +164,7 @@ module.exports.tests.query = function(test, common) {
});
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.end();
@ -177,7 +177,7 @@ module.exports.tests.query = function(test, common) {
});
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.end();

Loading…
Cancel
Save