Peter Johnson 8 years ago
parent
commit
cb67dd58d8
  1. 114
      test/unit/fixture/autocomplete_linguistic_final_token.js
  2. 172
      test/unit/fixture/autocomplete_linguistic_focus.js
  3. 172
      test/unit/fixture/autocomplete_linguistic_focus_null_island.js
  4. 138
      test/unit/fixture/autocomplete_linguistic_multiple_tokens.js
  5. 102
      test/unit/fixture/autocomplete_linguistic_only.js
  6. 274
      test/unit/fixture/autocomplete_linguistic_with_admin.js
  7. 268
      test/unit/fixture/autocomplete_single_character_street.js
  8. 112
      test/unit/fixture/autocomplete_with_source_filtering.js
  9. 33
      test/unit/fixture/reverse_null_island.js
  10. 33
      test/unit/fixture/reverse_standard.js
  11. 48
      test/unit/fixture/reverse_with_boundary_country.js
  12. 43
      test/unit/fixture/reverse_with_source_filtering.js
  13. 144
      test/unit/fixture/search_boundary_country.js
  14. 224
      test/unit/fixture/search_full_address.js
  15. 144
      test/unit/fixture/search_linguistic_bbox.js
  16. 176
      test/unit/fixture/search_linguistic_focus.js
  17. 198
      test/unit/fixture/search_linguistic_focus_bbox.js
  18. 176
      test/unit/fixture/search_linguistic_focus_null_island.js
  19. 120
      test/unit/fixture/search_linguistic_only.js
  20. 188
      test/unit/fixture/search_linguistic_viewport.js
  21. 160
      test/unit/fixture/search_partial_address.js
  22. 192
      test/unit/fixture/search_regions_address.js
  23. 132
      test/unit/fixture/search_with_source_filtering.js
  24. 10
      test/unit/query/reverse.js
  25. 4
      test/unit/query/search.js

114
test/unit/fixture/autocomplete_linguistic_final_token.js

@ -1,77 +1,73 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'boost': 1,
'slop': 3,
'query': 'one',
'type': 'phrase'
}
}
}],
'should':[{
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'boost': 1,
'slop': 3,
'query': 'one',
'type': 'phrase'
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'boost': 1,
'slop': 3,
'query': 'one',
'type': 'phrase'
}
}
}],
'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': {
'analyzer': 'peliasPhrase',
'boost': 1,
'slop': 3,
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'one',
'type': 'phrase'
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'one',
}
}
},
'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': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'one',
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
}
}]
}
},
'sort': [ '_score' ],

172
test/unit/fixture/autocomplete_linguistic_focus.js

@ -1,10 +1,21 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'query': 'test',
'type': 'phrase',
'operator': 'and'
}
}
}],
'should': [{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
@ -14,98 +25,83 @@ module.exports = {
'operator': 'and'
}
}
}],
'should': [{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'query': 'test',
'type': 'phrase',
'operator': 'and'
}
}
},
'functions': [{
'linear': {
'center_point': {
'origin': {
'lat': 29.49136,
'lon': -82.50622
},
'offset': '0km',
'scale': '250km',
'decay': 0.5
}
},
'functions': [{
'linear': {
'center_point': {
'origin': {
'lat': 29.49136,
'lon': -82.50622
},
'weight': 40
}],
'score_mode': 'avg',
'boost_mode': 'multiply',
'filter': {
'or': [
{
'term': {
'layer': 'venue'
}
},
{
'term': {
'layer': 'address'
}
}
]
'offset': '0km',
'scale': '250km',
'decay': 0.5
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'test',
}
},
'weight': 40
}],
'score_mode': 'avg',
'boost_mode': 'multiply',
'filter': {
'or': [
{
'term': {
'layer': 'venue'
}
},
'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': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'test',
}
{
'term': {
'layer': 'address'
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
]
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': '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': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'test',
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
}
}]
}
},
'sort': [ '_score' ],

172
test/unit/fixture/autocomplete_linguistic_focus_null_island.js

@ -1,10 +1,21 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'query': 'test',
'type': 'phrase',
'operator': 'and'
}
}
}],
'should': [{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
@ -14,98 +25,83 @@ module.exports = {
'operator': 'and'
}
}
}],
'should': [{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'query': 'test',
'type': 'phrase',
'operator': 'and'
}
}
},
'functions': [{
'linear': {
'center_point': {
'origin': {
'lat': 0,
'lon': 0
},
'offset': '0km',
'scale': '250km',
'decay': 0.5
}
},
'functions': [{
'linear': {
'center_point': {
'origin': {
'lat': 0,
'lon': 0
},
'weight': 40
}],
'score_mode': 'avg',
'boost_mode': 'multiply',
'filter': {
'or': [
{
'term': {
'layer': 'venue'
}
},
{
'term': {
'layer': 'address'
}
}
]
'offset': '0km',
'scale': '250km',
'decay': 0.5
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'test',
}
},
'weight': 40
}],
'score_mode': 'avg',
'boost_mode': 'multiply',
'filter': {
'or': [
{
'term': {
'layer': 'venue'
}
},
'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': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'test',
}
{
'term': {
'layer': 'address'
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
]
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': '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': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'test',
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
}
}]
}
},
'sort': [ '_score' ],

138
test/unit/fixture/autocomplete_linguistic_multiple_tokens.js

@ -1,90 +1,86 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'type': 'phrase',
'boost': 1,
'slop': 3,
'query': 'one two'
}
}
},
{
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'query': 'three',
'type': 'phrase',
'operator': 'and'
}
}
}],
'should':[
{
'match': {
'phrase.default': {
'analyzer' : 'peliasPhrase',
'type' : 'phrase',
'boost' : 1,
'slop' : 3,
'query' : 'one two'
}
}
},
{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'type': 'phrase',
'boost': 1,
'slop': 3,
'query': 'one two'
'query': 'one two three',
}
}
},
{
'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': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'query': 'three',
'type': 'phrase',
'operator': 'and'
'analyzer': 'peliasQueryFullToken',
'query': 'one two three',
}
}
}],
'should':[
{
'match': {
'phrase.default': {
'analyzer' : 'peliasPhrase',
'type' : 'phrase',
'boost' : 1,
'slop' : 3,
'query' : 'one two'
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'one two three',
}
}
},
'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': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'one two three',
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
'weight': 3
}]
}
}
}]
}
},
'sort': [ '_score' ],

102
test/unit/fixture/autocomplete_linguistic_only.js

@ -1,67 +1,63 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'query': 'test',
'type': 'phrase',
'operator': 'and'
}
}
}],
'should':[{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'analyzer': 'peliasQueryFullToken',
'query': 'test',
'type': 'phrase',
'operator': 'and'
}
}
}],
'should':[{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': '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': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'test',
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
},
'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': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'test',
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
}
}]
}
},
'sort': [ '_score' ],

274
test/unit/fixture/autocomplete_linguistic_with_admin.js

@ -1,159 +1,155 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [
{
'bool': {
'must': [
{
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'type': 'phrase',
'boost': 1,
'slop': 3,
'query': 'one two'
}
}
}
],
'should': [
{
'match': {
'parent.country': {
'analyzer': 'peliasAdmin',
'boost': 800,
'query': 'three'
}
}
},
{
'match': {
'parent.region': {
'analyzer': 'peliasAdmin',
'boost': 600,
'query': 'three'
}
}
},
{
'match': {
'parent.region_a': {
'analyzer': 'peliasAdmin',
'boost': 600,
'query': 'three'
}
}
},
{
'match': {
'parent.county': {
'analyzer': 'peliasAdmin',
'boost': 400,
'query': 'three'
}
}
},
{
'match': {
'parent.borough': {
'analyzer': 'peliasAdmin',
'boost': 600,
'query': 'three'
}
}
},
{
'match': {
'parent.localadmin': {
'analyzer': 'peliasAdmin',
'boost': 200,
'query': 'three'
}
}
},
{
'match': {
'parent.locality': {
'analyzer': 'peliasAdmin',
'boost': 200,
'query': 'three'
}
}
},
{
'match': {
'parent.neighbourhood': {
'analyzer': 'peliasAdmin',
'boost': 200,
'query': 'three'
}
}
},
{
'match': {
'phrase.default': {
'analyzer' : 'peliasPhrase',
'type' : 'phrase',
'boost' : 1,
'slop' : 3,
'query' : 'one two'
}
}
},
{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'type': 'phrase',
'boost': 1,
'slop': 3,
'query': 'one two'
}
}
}
],
'should': [
{
'match': {
'parent.country': {
'analyzer': 'peliasAdmin',
'boost': 800,
'query': 'three'
}
}
},
{
'match': {
'parent.region': {
'analyzer': 'peliasAdmin',
'boost': 600,
'query': 'three'
'query': 'one two',
}
}
},
{
'match': {
'parent.region_a': {
'analyzer': 'peliasAdmin',
'boost': 600,
'query': 'three'
}
}
},
{
'match': {
'parent.county': {
'analyzer': 'peliasAdmin',
'boost': 400,
'query': 'three'
}
}
},
{
'match': {
'parent.borough': {
'analyzer': 'peliasAdmin',
'boost': 600,
'query': 'three'
}
}
},
{
'match': {
'parent.localadmin': {
'analyzer': 'peliasAdmin',
'boost': 200,
'query': 'three'
}
}
},
{
'match': {
'parent.locality': {
'analyzer': 'peliasAdmin',
'boost': 200,
'query': 'three'
}
}
},
{
'match': {
'parent.neighbourhood': {
'analyzer': 'peliasAdmin',
'boost': 200,
'query': 'three'
}
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}
},
{
],
'score_mode': 'first',
'boost_mode': 'replace'
}
},
{
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer' : 'peliasPhrase',
'type' : 'phrase',
'boost' : 1,
'slop' : 3,
'query' : 'one two'
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'one two',
}
}
},
{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'one two',
}
}
},
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}
],
'score_mode': 'first',
'boost_mode': 'replace'
}
},
{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'one two',
}
}
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}
],
'score_mode': 'first',
'boost_mode': 'replace'
'weight': 3
}
}
]
],
'score_mode': 'first',
'boost_mode': 'replace'
}
}
}
]
}
},
'size': 20,

268
test/unit/fixture/autocomplete_single_character_street.js

@ -1,152 +1,148 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'type': 'phrase',
'boost': 1,
'slop': 3,
'query': 'k road'
}
}
}],
'should':[
{
'match': {
'address_parts.street': {
'query': 'k road',
'boost': 5,
'analyzer': 'peliasStreet'
}
}
}, {
'match': {
'parent.country': {
'query': 'laird',
'boost': 800,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.region': {
'query': 'laird',
'boost': 600,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.region_a': {
'query': 'laird',
'boost': 600,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.county': {
'query': 'laird',
'boost': 400,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.borough': {
'analyzer': 'peliasAdmin',
'boost': 600,
'query': 'laird'
}
}
}, {
'match': {
'parent.localadmin': {
'query': 'laird',
'boost': 200,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.locality': {
'query': 'laird',
'boost': 200,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.neighbourhood': {
'query': 'laird',
'boost': 200,
'analyzer': 'peliasAdmin'
}
}
},
{
'match': {
'phrase.default': {
'analyzer' : 'peliasPhrase',
'type' : 'phrase',
'boost' : 1,
'slop' : 3,
'query' : 'k road'
}
}
},
{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'type': 'phrase',
'boost': 1,
'slop': 3,
'query': 'k road'
'query': 'k road',
}
}
}],
'should':[
{
'match': {
'address_parts.street': {
'query': 'k road',
'boost': 5,
'analyzer': 'peliasStreet'
}
}
}, {
'match': {
'parent.country': {
'query': 'laird',
'boost': 800,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.region': {
'query': 'laird',
'boost': 600,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.region_a': {
'query': 'laird',
'boost': 600,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.county': {
'query': 'laird',
'boost': 400,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.borough': {
'analyzer': 'peliasAdmin',
'boost': 600,
'query': 'laird'
}
}
}, {
'match': {
'parent.localadmin': {
'query': 'laird',
'boost': 200,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.locality': {
'query': 'laird',
'boost': 200,
'analyzer': 'peliasAdmin'
}
}
}, {
'match': {
'parent.neighbourhood': {
'query': 'laird',
'boost': 200,
'analyzer': 'peliasAdmin'
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
{
'match': {
'phrase.default': {
'analyzer' : 'peliasPhrase',
'type' : 'phrase',
'boost' : 1,
'slop' : 3,
'query' : 'k road'
}
'weight': 1
}]
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'k road',
}
},
{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'k road',
}
}
},
'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': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'k road',
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
}
}]
}
},
'sort': [ '_score' ],

112
test/unit/fixture/autocomplete_with_source_filtering.js

@ -1,76 +1,68 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'query': 'test',
'type': 'phrase',
'operator': 'and'
}
}
}],
'should':[{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'analyzer': 'peliasQueryFullToken',
'query': 'test',
'type': 'phrase',
'operator': 'and'
}
}
}],
'should':[{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': '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': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'test',
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
}]
}
},
'filter': {
'bool': {
'must': [{
'terms': {
'source': ['test_source']
},{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasQueryFullToken',
'query': 'test',
}
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 3
}]
}
}
}],
'filter': [{
'terms': {
'source': ['test_source']
}
}]
}
},
'sort': [ '_score' ],

33
test/unit/fixture/reverse_null_island.js

@ -2,29 +2,18 @@ var vs = require('../../../query/reverse_defaults');
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': []
'bool': {
'filter': [{
'geo_distance': {
'distance': '500km',
'distance_type': 'plane',
'optimize_bbox': 'indexed',
'center_point': {
'lat': 0,
'lon': 0
}
}
},
'filter': {
'bool': {
'must': [
{
'geo_distance': {
'distance': '500km',
'distance_type': 'plane',
'optimize_bbox': 'indexed',
'center_point': {
'lat': 0,
'lon': 0
}
}
}
]
}
}
}]
}
},
'sort': [

33
test/unit/fixture/reverse_standard.js

@ -2,29 +2,18 @@ var vs = require('../../../query/reverse_defaults');
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': []
'bool': {
'filter': [{
'geo_distance': {
'distance': '500km',
'distance_type': 'plane',
'optimize_bbox': 'indexed',
'center_point': {
'lat': 29.49136,
'lon': -82.50622
}
}
},
'filter': {
'bool': {
'must': [
{
'geo_distance': {
'distance': '500km',
'distance_type': 'plane',
'optimize_bbox': 'indexed',
'center_point': {
'lat': 29.49136,
'lon': -82.50622
}
}
}
]
}
}
}]
}
},
'sort': [

48
test/unit/fixture/reverse_with_boundary_country.js

@ -2,38 +2,28 @@ var vs = require('../../../query/reverse_defaults');
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
}
'bool': {
'must': [
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
]
}
}
},
'filter': {
'bool': {
'must': [
{
'geo_distance': {
'distance': '500km',
'distance_type': 'plane',
'optimize_bbox': 'indexed',
'center_point': {
'lat': 29.49136,
'lon': -82.50622
}
}
}
]
],
'filter': [{
'geo_distance': {
'distance': '500km',
'distance_type': 'plane',
'optimize_bbox': 'indexed',
'center_point': {
'lat': 29.49136,
'lon': -82.50622
}
}
}
}]
}
},
'sort': [

43
test/unit/fixture/reverse_with_source_filtering.js

@ -2,34 +2,25 @@ var vs = require('../../../query/reverse_defaults');
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': []
}
},
'filter': {
'bool': {
'must': [
{
'geo_distance': {
'distance': '500km',
'distance_type': 'plane',
'optimize_bbox': 'indexed',
'center_point': {
'lat': 29.49136,
'lon': -82.50622
}
}
},
{
'terms': {
'source': ['test']
}
'bool': {
'filter': [
{
'geo_distance': {
'distance': '500km',
'distance_type': 'plane',
'optimize_bbox': 'indexed',
'center_point': {
'lat': 29.49136,
'lon': -82.50622
}
]
}
},
{
'terms': {
'source': ['test']
}
}
}
]
}
},
'sort': [

144
test/unit/fixture/search_boundary_country.js

@ -1,91 +1,87 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
}
},
{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
}
}
'bool': {
'must': [
{
'match': {
'parent.country_a': {
'analyzer': 'standard',
'query': 'ABC'
}
],
'should': [{
}
},
{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
}
}
}
],
'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',
'boost': 1,
'slop': 2
'slop': 2,
'boost': 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': '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
}]
},
'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
}]
}
}
}]
}
},
'sort': [ '_score' ],

224
test/unit/fixture/search_full_address.js

@ -2,19 +2,55 @@ var vs = require('../../../query/search_defaults');
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'query': '123 main st',
'analyzer': 'peliasIndexOneEdgeGram',
'boost': 1
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': '123 main st',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},
{
'function_score': {
'query': {
'match': {
'name.default': {
'phrase.default': {
'query': '123 main st',
'analyzer': 'peliasIndexOneEdgeGram',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
}],
'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': '123 main st',
@ -25,114 +61,74 @@ module.exports = {
}
}
},
{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': '123 main st',
'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': '123 main st',
'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
}]
}
},{
'match': {
'address_parts.number': {
'query': '123',
'boost': vs['address:housenumber:boost'],
'analyzer': vs['address:housenumber:analyzer']
}
}
}, {
'match': {
'address_parts.street': {
'query': 'main st',
'boost': vs['address:street:boost'],
'analyzer': vs['address:street:analyzer']
}
}
}, {
'match': {
'address_parts.zip': {
'query': '10010',
'boost': vs['address:postcode:boost'],
'analyzer': vs['address:postcode:analyzer']
}
}
}, {
'match': {
'parent.country_a': {
'query': 'USA',
'boost': vs['admin:country_a:boost'],
'analyzer': vs['admin:country_a:analyzer']
}
}
}, {
'match': {
'parent.region_a': {
'query': 'NY',
'boost': vs['admin:region_a:boost'],
'analyzer': vs['admin:region_a:analyzer']
}
}
}, {
'multi_match': {
'fields': [
'parent.country^1',
'parent.region^1',
'parent.county^1',
'parent.localadmin^1',
'parent.locality^1',
'parent.borough^1',
'parent.neighbourhood^1',
'parent.region_a^1'
],
'query': 'new york',
'analyzer': 'peliasAdmin'
}
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}
},{
'match': {
'address_parts.number': {
'query': '123',
'boost': vs['address:housenumber:boost'],
'analyzer': vs['address:housenumber:analyzer']
}
}
}, {
'match': {
'address_parts.street': {
'query': 'main st',
'boost': vs['address:street:boost'],
'analyzer': vs['address:street:analyzer']
}
}
}, {
'match': {
'address_parts.zip': {
'query': '10010',
'boost': vs['address:postcode:boost'],
'analyzer': vs['address:postcode:analyzer']
}
}
}, {
'match': {
'parent.country_a': {
'query': 'USA',
'boost': vs['admin:country_a:boost'],
'analyzer': vs['admin:country_a:analyzer']
}
}
}, {
'match': {
'parent.region_a': {
'query': 'NY',
'boost': vs['admin:region_a:boost'],
'analyzer': vs['admin:region_a:analyzer']
}
}
}, {
'multi_match': {
'fields': [
'parent.country^1',
'parent.region^1',
'parent.county^1',
'parent.localadmin^1',
'parent.locality^1',
'parent.borough^1',
'parent.neighbourhood^1',
'parent.region_a^1'
],
'query': 'new york',
'analyzer': 'peliasAdmin'
}
}]
}
},
'size': 10,

144
test/unit/fixture/search_linguistic_bbox.js

@ -1,96 +1,88 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'phrase.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
}],
'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',
'boost': 1,
'slop': 2
'slop': 2,
'boost': 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': '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
}]
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
},
'filter': {
'bool': {
'must': [{
'geo_bounding_box': {
'center_point': {
'top': 11.51,
'right': -61.84,
'bottom': 47.47,
'left': -103.16
},
'type': 'indexed'
}
}]
}],
'filter': [{
'geo_bounding_box': {
'center_point': {
'top': 11.51,
'right': -61.84,
'bottom': 47.47,
'left': -103.16
},
'type': 'indexed'
}
}
}]
}
},
'sort': [ '_score' ],

176
test/unit/fixture/search_linguistic_focus.js

@ -1,111 +1,107 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
}, {
'function_score': {
'query': {
'match': {
'name.default': {
'query': 'test',
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
'slop': 2,
'query': 'test'
}
}
},
'functions': [{
'linear': {
'center_point': {
'origin': {
'lat': 29.49136,
'lon': -82.50622
},
'offset': '1km',
'scale': '50km',
'decay': 0.5
}
},
'weight': 2
}],
'should': [{
'score_mode': 'avg',
'boost_mode': 'replace'
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
'slop': 2,
'boost': 1
}
}
}, {
'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': '1km',
'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
}]
},
'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
}]
}
}
}]
}
},
'sort': [ '_score' ],

198
test/unit/fixture/search_linguistic_focus_bbox.js

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

176
test/unit/fixture/search_linguistic_focus_null_island.js

@ -1,111 +1,107 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
}, {
'function_score': {
'query': {
'match': {
'name.default': {
'query': 'test',
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
'slop': 2,
'query': 'test'
}
}
},
'functions': [{
'linear': {
'center_point': {
'origin': {
'lat': 0,
'lon': 0
},
'offset': '1km',
'scale': '50km',
'decay': 0.5
}
},
'weight': 2
}],
'should': [{
'score_mode': 'avg',
'boost_mode': 'replace'
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
'slop': 2,
'boost': 1
}
}
}, {
'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': '1km',
'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
}]
},
'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
}]
}
}
}]
}
},
'sort': [ '_score' ],

120
test/unit/fixture/search_linguistic_only.js

@ -1,81 +1,77 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'phrase.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
}],
'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',
'boost': 1,
'slop': 2
'slop': 2,
'boost': 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': '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
}]
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}
}]
}
},
'sort': [ '_score' ],

188
test/unit/fixture/search_linguistic_viewport.js

@ -1,21 +1,65 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [
{
'bool': {
'must': [
{
'match': {
'name.default': {
'analyzer': 'peliasIndexOneEdgeGram',
'boost': 1,
'query': 'test'
}
}
}
],
'should': [
{
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
},
{
'function_score': {
'query': {
'match': {
'name.default': {
'analyzer': 'peliasIndexOneEdgeGram',
'phrase.default': {
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2,
'query': 'test'
}
}
}
],
'should': [
{
},
'functions': [
{
'weight': 2,
'linear': {
'center_point': {
'origin': {
'lat': 29.49136,
'lon': -82.50622
},
'offset': '1km',
'scale': '50km',
'decay': 0.5
}
}
}
],
'score_mode': 'avg',
'boost_mode': 'replace'
}
},
{
'function_score': {
'query': {
'match': {
'phrase.default': {
'analyzer': 'peliasPhrase',
@ -26,98 +70,50 @@ module.exports = {
}
}
},
{
'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
},
'functions': [
{
'weight': 2,
'linear': {
'center_point': {
'origin': {
'lat': 29.49136,
'lon': -82.50622
},
'offset': '1km',
'scale': '50km',
'decay': 0.5
}
}
}
],
'score_mode': 'avg',
'boost_mode': 'replace'
'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': 'popularity',
'missing': 1
},
'weight': 1
}
],
'score_mode': 'first',
'boost_mode': 'replace'
],
'score_mode': 'first',
'boost_mode': 'replace'
}
},
{
'function_score': {
'query': {
'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'
}
}
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}
],
'score_mode': 'first',
'boost_mode': 'replace'
'weight': 2
}
}
]
],
'score_mode': 'first',
'boost_mode': 'replace'
}
}
}
]
}
},
'size': 10,

160
test/unit/fixture/search_partial_address.js

@ -3,19 +3,54 @@ var vs = require('../../../query/search_defaults');
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'soho grand',
'analyzer': 'peliasIndexOneEdgeGram',
'boost': 1
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'soho grand',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'phrase.default': {
'query': 'soho grand',
'analyzer': 'peliasIndexOneEdgeGram',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
}],
'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': 'soho grand',
@ -25,82 +60,43 @@ module.exports = {
'boost': 1
}
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': 'soho grand',
'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': 'soho grand',
'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
}]
}
}, {
'match': {
'parent.region_a': {
'analyzer': 'peliasAdmin',
'boost': 1,
'query': 'new york'
}
}
}, {
'multi_match': {
'fields': [
'parent.country^1',
'parent.region^1',
'parent.county^1',
'parent.localadmin^1',
'parent.locality^1',
'parent.borough^1',
'parent.neighbourhood^1',
'parent.region_a^1'
],
'query': 'new york',
'analyzer': 'peliasAdmin'
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}
}, {
'match': {
'parent.region_a': {
'analyzer': 'peliasAdmin',
'boost': 1,
'query': 'new york'
}
}
}, {
'multi_match': {
'fields': [
'parent.country^1',
'parent.region^1',
'parent.county^1',
'parent.localadmin^1',
'parent.locality^1',
'parent.borough^1',
'parent.neighbourhood^1',
'parent.region_a^1'
],
'query': 'new york',
'analyzer': 'peliasAdmin'
}
}]
}
},
'size': 10,

192
test/unit/fixture/search_regions_address.js

@ -3,19 +3,54 @@ var vs = require('../../../query/search_defaults');
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'query': '1 water st',
'analyzer': 'peliasIndexOneEdgeGram',
'boost': 1
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': '1 water st',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'phrase.default': {
'query': '1 water st',
'analyzer': 'peliasIndexOneEdgeGram',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
}],
'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': '1 water st',
@ -25,98 +60,59 @@ module.exports = {
'boost': 1
}
}
},{
'function_score': {
'query': {
'match': {
'phrase.default': {
'query': '1 water st',
'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': '1 water st',
'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
}]
}
},{
'match': {
'address_parts.number': {
'query': '1',
'boost': vs['address:housenumber:boost'],
'analyzer': vs['address:housenumber:analyzer']
}
}
}, {
'match': {
'address_parts.street': {
'query': 'water st',
'boost': vs['address:street:boost'],
'analyzer': vs['address:street:analyzer']
}
}
}, {
'match': {
'parent.region_a': {
'query': 'NY',
'boost': vs['admin:region_a:boost'],
'analyzer': vs['admin:region_a:analyzer']
}
}
}, {
'multi_match': {
'fields': [
'parent.country^1',
'parent.region^1',
'parent.county^1',
'parent.localadmin^1',
'parent.locality^1',
'parent.borough^1',
'parent.neighbourhood^1',
'parent.region_a^1'
],
'query': 'manhattan',
'analyzer': 'peliasAdmin'
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
}
},{
'match': {
'address_parts.number': {
'query': '1',
'boost': vs['address:housenumber:boost'],
'analyzer': vs['address:housenumber:analyzer']
}
}
}, {
'match': {
'address_parts.street': {
'query': 'water st',
'boost': vs['address:street:boost'],
'analyzer': vs['address:street:analyzer']
}
}
}, {
'match': {
'parent.region_a': {
'query': 'NY',
'boost': vs['admin:region_a:boost'],
'analyzer': vs['admin:region_a:analyzer']
}
}
}, {
'multi_match': {
'fields': [
'parent.country^1',
'parent.region^1',
'parent.county^1',
'parent.localadmin^1',
'parent.locality^1',
'parent.borough^1',
'parent.neighbourhood^1',
'parent.region_a^1'
],
'query': 'manhattan',
'analyzer': 'peliasAdmin'
}
}]
}
},
'size': 10,

132
test/unit/fixture/search_with_source_filtering.js

@ -1,90 +1,82 @@
module.exports = {
'query': {
'filtered': {
'query': {
'bool': {
'must': [{
'bool': {
'must': [{
'match': {
'name.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
}
}
}],
'should': [{
'match': {
'phrase.default': {
'query': 'test',
'analyzer': 'peliasPhrase',
'type': 'phrase',
'boost': 1,
'slop': 2
}
}
},{
'function_score': {
'query': {
'match': {
'name.default': {
'phrase.default': {
'query': 'test',
'boost': 1,
'analyzer': 'peliasIndexOneEdgeGram'
'analyzer': 'peliasPhrase',
'type': 'phrase',
'slop': 2,
'boost': 1
}
}
}],
'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',
'boost': 1,
'slop': 2
'slop': 2,
'boost': 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': '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
}]
}
},
'max_boost': 20,
'score_mode': 'first',
'boost_mode': 'replace',
'functions': [{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}]
}
},
'filter': {
'bool': {
'must': [{
'terms': {
'source': ['test_source']
}
}]
}],
'filter': [{
'terms': {
'source': ['test_source']
}
}
}]
}
},
'sort': [ '_score' ],

10
test/unit/query/reverse.js

@ -22,7 +22,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/reverse_standard');
t.deepEqual(compiled, expected, 'valid reverse query');
t.deepEqual(compiled, expected, 'reverse_standard');
t.end();
});
@ -38,7 +38,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/reverse_null_island');
t.deepEqual(compiled, expected, 'valid reverse query');
t.deepEqual(compiled, expected, 'reverse_null_island');
t.end();
});
@ -54,7 +54,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = '123km';
t.deepEqual(compiled.query.filtered.filter.bool.must[0].geo_distance.distance, expected, 'distance set to boundary circle radius');
t.deepEqual(compiled.query.bool.filter[0].geo_distance.distance, expected, 'distance set to boundary circle radius');
t.end();
});
@ -71,9 +71,9 @@ module.exports.tests.query = function(test, common) {
// this should not equal `point.lat` and `point.lon` as it was explitely specified
var expected = { lat: clean['boundary.circle.lat'], lon: clean['boundary.circle.lon'] };
var centroid = compiled.query.filtered.filter.bool.must[0].geo_distance.center_point;
var centroid = compiled.query.bool.filter[0].geo_distance.center_point;
t.deepEqual(centroid, expected, 'boundary.circle/lon overrides point.lat/lon');
t.deepEqual(centroid, expected, 'reverse: boundary.circle/lon overrides point.lat/lon');
t.end();
});

4
test/unit/query/search.js

@ -178,7 +178,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_boundary_country');
t.deepEqual(compiled, expected, 'valid boundary.country query');
t.deepEqual(compiled, expected, 'search: valid boundary.country query');
t.end();
});
@ -191,7 +191,7 @@ module.exports.tests.query = function(test, common) {
var compiled = JSON.parse( JSON.stringify( query ) );
var expected = require('../fixture/search_with_source_filtering');
t.deepEqual(compiled, expected, 'valid search query with source filtering');
t.deepEqual(compiled, expected, 'search: valid search query with source filtering');
t.end();
});

Loading…
Cancel
Save