Browse Source

Merge pull request #823 from pelias/master

Merge master into staging
pull/833/head
Diana Shkolnikov 8 years ago committed by GitHub
parent
commit
3c5644e193
  1. 4
      package.json
  2. 5
      sanitizer/_synthesize_analysis.js
  3. 3
      test/ciao/autocomplete/layers_alias_coarse.coffee
  4. 2
      test/ciao/autocomplete/layers_invalid.coffee
  5. 2
      test/ciao/autocomplete/layers_mix_invalid_valid.coffee
  6. 3
      test/ciao/reverse/layers_alias_coarse.coffee
  7. 2
      test/ciao/reverse/layers_invalid.coffee
  8. 2
      test/ciao/reverse/layers_mix_invalid_valid.coffee
  9. 2
      test/ciao/search/address_parsing.coffee
  10. 3
      test/ciao/search/layers_alias_coarse.coffee
  11. 2
      test/ciao/search/layers_invalid.coffee
  12. 2
      test/ciao/search/layers_mix_invalid_valid.coffee
  13. 69
      test/unit/fixture/structured_geocoding/fallback.json
  14. 68
      test/unit/fixture/structured_geocoding/postalcode_only.js
  15. 18
      test/unit/query/structured_geocoding.js
  16. 2
      test/unit/sanitizer/_synthesize_analysis.js

4
package.json

@ -58,7 +58,7 @@
"pelias-logger": "0.1.0",
"pelias-mock-logger": "^1.0.1",
"pelias-model": "4.5.1",
"pelias-query": "8.13.0",
"pelias-query": "8.14.0",
"pelias-text-analyzer": "1.7.2",
"predicates": "^1.0.1",
"retry": "^0.10.1",
@ -67,7 +67,7 @@
"through2": "^2.0.3"
},
"devDependencies": {
"ciao": "^0.6.0",
"ciao": "^1.0.0",
"difflet": "^1.0.1",
"istanbul": "^0.4.2",
"jshint": "^2.5.6",

5
sanitizer/_synthesize_analysis.js

@ -50,10 +50,7 @@ function sanitize( raw, clean ){
}, {});
if (isPostalCodeOnly(clean.parsed_text)) {
messages.errors.push('postalcode-only inputs are not supported');
}
else if (_.isEmpty(Object.keys(clean.parsed_text))) {
if (_.isEmpty(Object.keys(clean.parsed_text))) {
messages.errors.push(
`at least one of the following fields is required: ${Object.keys(fields).join(', ')}`);
}

3
test/ciao/autocomplete/layers_alias_coarse.coffee

@ -44,5 +44,6 @@ json.geocoding.query.layers.should.eql [ "continent",
"borough",
"neighbourhood",
"microhood",
"disputed"
"disputed",
"postalcode"
]

2
test/ciao/autocomplete/layers_invalid.coffee

@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed' ]
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed,postalcode' ]
#? expected warnings
should.not.exist json.geocoding.warnings

2
test/ciao/autocomplete/layers_mix_invalid_valid.coffee

@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed' ]
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed,postalcode' ]
#? expected warnings
should.not.exist json.geocoding.warnings

3
test/ciao/reverse/layers_alias_coarse.coffee

@ -43,5 +43,6 @@ json.geocoding.query.layers.should.eql [ "continent",
"borough",
"neighbourhood",
"microhood",
"disputed"
"disputed",
"postalcode"
]

2
test/ciao/reverse/layers_invalid.coffee

@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed' ]
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed,postalcode' ]
#? expected warnings
should.not.exist json.geocoding.warnings

2
test/ciao/reverse/layers_mix_invalid_valid.coffee

@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed' ]
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed,postalcode' ]
#? expected warnings
should.not.exist json.geocoding.warnings

2
test/ciao/search/address_parsing.coffee

@ -35,7 +35,7 @@ json.geocoding.query['size'].should.eql 10
#? address parsing
json.geocoding.query.parsed_text['number'].should.eql '30'
json.geocoding.query.parsed_text['street'].should.eql 'w 26th st'
json.geocoding.query.parsed_text['state'].should.eql 'NY'
json.geocoding.query.parsed_text['state'].should.eql 'ny'
json.features[0].properties.confidence.should.eql 1
json.features[0].properties.match_type.should.eql "exact"

3
test/ciao/search/layers_alias_coarse.coffee

@ -44,5 +44,6 @@ json.geocoding.query.layers.should.eql [ "continent",
"borough",
"neighbourhood",
"microhood",
"disputed"
"disputed",
"postalcode"
]

2
test/ciao/search/layers_invalid.coffee

@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed' ]
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed,postalcode' ]
#? expected warnings
should.not.exist json.geocoding.warnings

2
test/ciao/search/layers_mix_invalid_valid.coffee

@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors
should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed' ]
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,street,country,macroregion,region,county,localadmin,locality,borough,neighbourhood,continent,dependency,macrocounty,macrohood,microhood,disputed,postalcode' ]
#? expected warnings
should.not.exist json.geocoding.warnings

69
test/unit/fixture/structured_geocoding/fallback.json

@ -287,6 +287,75 @@
"boost": 5
}
},
{
"bool": {
"_name": "fallback.postalcode",
"must": [
{
"multi_match": {
"query": "postalcode value",
"type": "phrase",
"fields": [
"parent.postalcode"
]
}
},
{
"multi_match": {
"query": "city value",
"type": "phrase",
"fields": [
"parent.locality",
"parent.locality_a",
"parent.localadmin",
"parent.localadmin_a"
]
}
},
{
"multi_match": {
"query": "county value",
"type": "phrase",
"fields": [
"parent.county",
"parent.county_a",
"parent.macrocounty",
"parent.macrocounty_a"
]
}
},
{
"multi_match": {
"query": "state value",
"type": "phrase",
"fields": [
"parent.region",
"parent.region_a",
"parent.macroregion",
"parent.macroregion_a"
]
}
},
{
"multi_match": {
"query": "country value",
"type": "phrase",
"fields": [
"parent.country",
"parent.country_a",
"parent.dependency",
"parent.dependency_a"
]
}
}
],
"filter": {
"term": {
"layer": "postalcode"
}
}
}
},
{
"bool": {
"_name": "fallback.neighbourhood",

68
test/unit/fixture/structured_geocoding/postalcode_only.js

@ -0,0 +1,68 @@
module.exports = {
'query': {
'function_score': {
'query': {
'filtered': {
'query': {
'bool': {
'should': [
{
'bool': {
'_name': 'fallback.postalcode',
'must': [
{
'multi_match': {
'query': 'postalcode value',
'type': 'phrase',
'fields': [
'parent.postalcode'
]
}
}
],
'filter': {
'term': {
'layer': 'postalcode'
}
}
}
}
]
}
},
'filter': {
'bool': {
'must': []
}
}
}
},
'max_boost': 20,
'functions': [
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'popularity',
'missing': 1
},
'weight': 1
},
{
'field_value_factor': {
'modifier': 'log1p',
'field': 'population',
'missing': 1
},
'weight': 2
}
],
'score_mode': 'avg',
'boost_mode': 'multiply'
}
},
'size': 20,
'track_scores': true,
'sort': [
'_score'
]
};

18
test/unit/query/structured_geocoding.js

@ -188,6 +188,24 @@ module.exports.tests.query = function(test, common) {
});
test('parsed_text with all fields should use FallbackQuery', function(t) {
var clean = {
parsed_text: {
postalcode: 'postalcode value'
}
};
var query = generate(clean);
var compiled = JSON.parse(JSON.stringify(query));
var expected = require('../fixture/structured_geocoding/postalcode_only');
t.deepEqual(compiled.type, 'fallback', 'query type set');
t.deepEqual(compiled.body, expected, 'structured postalcode only');
t.end();
});
test('valid boundary.country search', function(t) {
var clean = {
parsed_text: {

2
test/unit/sanitizer/_synthesize_analysis.js

@ -131,7 +131,7 @@ module.exports.tests.text_parser = function(test, common) {
const messages = sanitizer(raw, clean);
t.deepEquals(clean, expected_clean);
t.deepEquals(messages.errors, ['postalcode-only inputs are not supported'], 'no errors');
t.deepEquals(messages.errors, [], 'no errors');
t.deepEquals(messages.warnings, [], 'no warnings');
t.end();

Loading…
Cancel
Save