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. 80
      test/unit/fixture/search_boundary_country.js
  4. 99
      test/unit/fixture/search_boundary_country_original.js
  5. 32
      test/unit/fixture/search_fallback.js
  6. 0
      test/unit/fixture/search_full_address_original.js
  7. 32
      test/unit/fixture/search_geodisambiguation.js
  8. 100
      test/unit/fixture/search_linguistic_bbox.js
  9. 98
      test/unit/fixture/search_linguistic_bbox_original.js
  10. 102
      test/unit/fixture/search_linguistic_focus.js
  11. 122
      test/unit/fixture/search_linguistic_focus_bbox.js
  12. 128
      test/unit/fixture/search_linguistic_focus_bbox_original.js
  13. 100
      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. 80
      test/unit/fixture/search_linguistic_only.js
  17. 89
      test/unit/fixture/search_linguistic_only_original.js
  18. 110
      test/unit/fixture/search_linguistic_viewport.js
  19. 103
      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. 80
      test/unit/fixture/search_with_category_filtering.js
  23. 86
      test/unit/fixture/search_with_category_filtering_original.js
  24. 76
      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 );
// --------------------------------
/**

80
test/unit/fixture/search_boundary_country.js

@ -1,6 +1,14 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'should': []
}
},
'filter': {
'bool': {
'must': [
{
@ -12,88 +20,40 @@ module.exports = {
}
},
{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
}
}
'terms': {
'layer': [
'test'
]
}
],
'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': [{
'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'
]
}
}
]
],
'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
};

32
test/unit/fixture/search_fallback.js

@ -1,4 +1,8 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'should': [
@ -482,10 +486,17 @@ module.exports = {
}
}
}
}
]
}
},
'filter': {
'bool': {
'must': []
}
}
}
},
{
'function_score': {
'query': null,
'max_boost': 20,
'functions': [
{
@ -495,17 +506,7 @@ module.exports = {
'missing': 1
},
'weight': 1
}
],
'score_mode': 'first',
'boost_mode': 'replace'
}
},
{
'function_score': {
'query': null,
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
@ -515,12 +516,9 @@ module.exports = {
'weight': 2
}
],
'score_mode': 'first',
'score_mode': 'avg',
'boost_mode': 'replace'
}
}
]
}
},
'size': 20,
'track_scores': true

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

32
test/unit/fixture/search_geodisambiguation.js

@ -1,4 +1,8 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'should': [
@ -211,10 +215,17 @@ module.exports = {
}
}
}
}
]
}
},
'filter': {
'bool': {
'must': []
}
}
}
},
{
'function_score': {
'query': null,
'max_boost': 20,
'functions': [
{
@ -224,17 +235,7 @@ module.exports = {
'missing': 1
},
'weight': 1
}
],
'score_mode': 'first',
'boost_mode': 'replace'
}
},
{
'function_score': {
'query': null,
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
@ -244,12 +245,9 @@ module.exports = {
'weight': 2
}
],
'score_mode': 'first',
'score_mode': 'avg',
'boost_mode': 'replace'
}
}
]
}
},
'size': 20,
'track_scores': true

100
test/unit/fixture/search_linguistic_bbox.js

@ -1,98 +1,62 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'should': []
}
},
'filter': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
'must': [
{
'geo_bounding_box': {
'type': 'indexed',
'center_point': {
'top': 11.51,
'right': -61.84,
'bottom': 47.47,
'left': -103.16
}
}
},
{
'terms': {
'layer': [
'test'
]
}
}],
'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': [{
'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'
]
}
}]
],
'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
};

102
test/unit/fixture/search_linguistic_focus.js

@ -1,40 +1,32 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
'should': []
}
},
'filter': {
'bool': {
'must': [
{
'terms': {
'layer': [
'test'
]
}
}],
'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': [{
'max_boost': 20,
'functions': [
{
'weight': 2,
'linear': {
'center_point': {
'origin': {
@ -45,75 +37,29 @@ module.exports = {
'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'
]
}
}
]
],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},
'sort': [ '_score' ],
'size': 10,
'track_scores': true
};

122
test/unit/fixture/search_linguistic_focus_bbox.js

@ -1,40 +1,43 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
'should': []
}
},
'filter': {
'bool': {
'must': [
{
'geo_bounding_box': {
'type': 'indexed',
'center_point': {
'top': 11.51,
'right': -61.84,
'bottom': 47.47,
'left': -103.16
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
},
{
'terms': {
'layer': [
'test'
]
}
}
]
}
}, {
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
'functions': [{
'max_boost': 20,
'functions': [
{
'weight': 2,
'linear': {
'center_point': {
'origin': {
@ -45,84 +48,29 @@ module.exports = {
'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'
]
}
}]
],
'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
};

100
test/unit/fixture/search_linguistic_focus_null_island.js

@ -1,40 +1,32 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
'should': []
}
},
'filter': {
'bool': {
'must': [
{
'terms': {
'layer': [
'test'
]
}
}],
'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': [{
'max_boost': 20,
'functions': [
{
'weight': 2,
'linear': {
'center_point': {
'origin': {
@ -45,73 +37,29 @@ module.exports = {
'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'
]
}
}]
],
'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
};

80
test/unit/fixture/search_linguistic_only.js

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

110
test/unit/fixture/search_linguistic_viewport.js

@ -1,72 +1,25 @@
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': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
'filtered': {
'query': {
'bool': {
'should': []
}
},
'functions': [
'filter': {
'bool': {
'must': [
{
'weight': 2,
'linear': {
'center_point': {
'origin': {
'lat': 29.49136,
'lon': -82.50622
},
'offset': '0km',
'scale': '50km',
'decay': 0.5
'terms': {
'layer': [
'test'
]
}
}
]
}
],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},
{
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
@ -79,27 +32,7 @@ module.exports = {
'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',
@ -109,25 +42,10 @@ module.exports = {
'weight': 2
}
],
'score_mode': 'first',
'score_mode': 'avg',
'boost_mode': 'replace'
}
}
],
'filter': [
{
'terms': {
'layer': [
'test'
]
}
}
]
}
},
'size': 10,
'track_scores': true,
'sort': [
'_score'
]
'track_scores': true
};

103
test/unit/fixture/search_linguistic_viewport_min_diagonal.js

@ -1,74 +1,25 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'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'
}
'should': []
}
},
'filter': {
'bool': {
'must': [
{
'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
}
'terms': {
'layer': [
'test'
]
}
}
],
'score_mode': 'avg',
'boost_mode': 'replace'
]
}
},
{
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
@ -81,27 +32,7 @@ module.exports = {
'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',
@ -111,18 +42,10 @@ module.exports = {
'weight': 2
}
],
'score_mode': 'first',
'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

80
test/unit/fixture/search_with_category_filtering.js

@ -1,86 +1,52 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
'should': []
}
},
'filter': {
'bool': {
'must': [
{
'terms': {
'category': [
'retail',
'food'
]
}
}],
'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': [{
'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']
}
}]
],
'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'
]
};

76
test/unit/fixture/search_with_source_filtering.js

@ -1,85 +1,51 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasQueryFullToken'
'should': []
}
},
'filter': {
'bool': {
'must': [
{
'terms': {
'source': [
'test_source'
]
}
}],
'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': [{
'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']
}
}]
],
'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