Browse Source

📎 fix merge conflict

riordan/openaddresses-attribution
Riordan 9 years ago
parent
commit
b8d9dd8510
  1. 45
      helper/adminFields.js
  2. 34
      helper/geojsonify.js
  3. 4
      helper/labelGenerator.js
  4. 8
      helper/type_mapping.js
  5. 14
      middleware/confidenceScore.js
  6. 21
      middleware/dedupe.js
  7. 2
      middleware/localNamingConventions.js
  8. 71
      middleware/renamePlacenames.js
  9. 3
      package.json
  10. 5
      public/attribution.md
  11. 14
      query/autocomplete.js
  12. 44
      query/autocomplete_defaults.js
  13. 44
      query/reverse_defaults.js
  14. 14
      query/search.js
  15. 44
      query/search_defaults.js
  16. 27
      query/text_parser.js
  17. 7
      test/ciao/reverse/layers_alias_coarse.coffee
  18. 2
      test/ciao/reverse/layers_invalid.coffee
  19. 2
      test/ciao/reverse/layers_mix_invalid_valid.coffee
  20. 2
      test/ciao/reverse/layers_multiple.coffee
  21. 2
      test/ciao/reverse/layers_single.coffee
  22. 2
      test/ciao/reverse/sources_invalid.coffee
  23. 6
      test/ciao/reverse/sources_layers_invalid_combo.coffee
  24. 7
      test/ciao/search/layers_alias_coarse.coffee
  25. 2
      test/ciao/search/layers_invalid.coffee
  26. 2
      test/ciao/search/layers_mix_invalid_valid.coffee
  27. 2
      test/ciao/search/layers_multiple.coffee
  28. 2
      test/ciao/search/layers_single.coffee
  29. 2
      test/ciao/search/sources_invalid.coffee
  30. 6
      test/ciao/search/sources_layers_invalid_combo.coffee
  31. 16
      test/unit/controller/search.js
  32. 14
      test/unit/fixture/autocomplete_linguistic_with_admin.js
  33. 38
      test/unit/fixture/dedupe_elasticsearch_nonascii_results.js
  34. 204
      test/unit/fixture/dedupe_elasticsearch_results.js
  35. 2
      test/unit/fixture/reverse_with_boundary_country.js
  36. 2
      test/unit/fixture/search_boundary_country.js
  37. 48
      test/unit/fixture/search_full_address.js
  38. 38
      test/unit/fixture/search_partial_address.js
  39. 38
      test/unit/fixture/search_regions_address.js
  40. 84
      test/unit/helper/adminFields.js
  41. 6
      test/unit/helper/labelGenerator_GBR.js
  42. 4
      test/unit/helper/labelGenerator_SGP.js
  43. 4
      test/unit/helper/labelGenerator_SWE.js
  44. 24
      test/unit/helper/labelGenerator_USA.js
  45. 32
      test/unit/helper/labelGenerator_default.js
  46. 3
      test/unit/helper/type_mapping.js
  47. 14
      test/unit/middleware/confidenceScore.js
  48. 22
      test/unit/middleware/localNamingConventions.js
  49. 8
      test/unit/mock/backend.js
  50. 9
      test/unit/query/search.js
  51. 12
      test/unit/sanitiser/_layers.js
  52. 4
      test/unit/sanitiser/_sources.js
  53. 2
      test/unit/sanitiser/search.js
  54. 4
      test/unit/service/mget.js
  55. 4
      test/unit/service/search.js

45
helper/adminFields.js

@ -1,45 +0,0 @@
var _ = require('lodash'),
peliasSchema = require('pelias-schema'),
peliasLogger = require( 'pelias-logger' ).get( 'api' );
var ADMIN_FIELDS = [
'admin0',
'admin1',
'admin1_abbr',
'admin2',
'local_admin',
'locality',
'neighborhood',
'address.zip'
];
/**
* Get all admin fields that were expected and also found in schema
*
* @param {Object} [schema] optional: for testing only
* @param {Array} [expectedFields] optional: for testing only
* @param {Object} [logger] optional: for testing only
* @returns {Array.<string>}
*/
function getAvailableAdminFields(schema, expectedFields, logger) {
schema = schema || peliasSchema;
expectedFields = expectedFields || ADMIN_FIELDS;
logger = logger || peliasLogger;
var actualFields = Object.keys(schema.mappings._default_.properties);
// check if expected fields are actually in current schema
var available = expectedFields.filter(function (field) {
return _.includes( actualFields, field );
});
if (available.length === 0) {
logger.error('helper/adminFields: no expected admin fields found in schema');
}
return available;
}
module.exports = getAvailableAdminFields;

34
helper/geojsonify.js

@ -11,16 +11,25 @@ var DETAILS_PROPS = [
'housenumber', 'housenumber',
'street', 'street',
'postalcode', 'postalcode',
'country_a', 'confidence',
'distance',
'country', 'country',
'country_id',
'country_a',
'region', 'region',
'region_id',
'region_a', 'region_a',
'county', 'county',
'county_id',
'county_a',
'localadmin', 'localadmin',
'localadmin_id',
'localadmin_a',
'locality', 'locality',
'locality_id',
'locality_a',
'neighbourhood', 'neighbourhood',
'confidence', 'neighbourhood_id'
'distance'
]; ];
@ -93,7 +102,7 @@ function addDetails(src, dst) {
* @param {object} dst * @param {object} dst
*/ */
function addLabel(src, dst) { function addLabel(src, dst) {
dst.label = labelGenerator(src); dst.label = labelGenerator(dst);
} }
/** /**
@ -126,8 +135,23 @@ function computeBBox(geojson) {
*/ */
function copyProperties( source, props, dst ) { function copyProperties( source, props, dst ) {
props.forEach( function ( prop ) { props.forEach( function ( prop ) {
if ( source.hasOwnProperty( prop ) ) { if ( source.hasOwnProperty( prop ) ) {
dst[prop] = source[prop];
// array value, take first item in array (at this time only used for admin values)
if (source[prop] instanceof Array) {
if (source[prop].length === 0) {
return;
}
if (source[prop][0]) {
dst[prop] = source[prop][0];
}
}
// simple value
else {
dst[prop] = source[prop];
}
} }
}); });
} }

4
helper/labelGenerator.js

@ -1,4 +1,3 @@
var _ = require('lodash'), var _ = require('lodash'),
schemas = require('./labelSchema'); schemas = require('./labelSchema');
@ -11,7 +10,6 @@ module.exports = function( record ){
var valueFunction = schema[key]; var valueFunction = schema[key];
labelParts = valueFunction(record, labelParts); labelParts = valueFunction(record, labelParts);
} }
// NOTE: while it may seem odd to call `uniq` on the list of label parts, // NOTE: while it may seem odd to call `uniq` on the list of label parts,
@ -54,6 +52,6 @@ function getInitialLabel(record) {
return []; return [];
} }
return [record.name.default]; return [record.name];
} }

8
helper/type_mapping.js

@ -17,7 +17,7 @@ function addStandardTargetsToAliases(standard, aliases) {
*/ */
// a list of all sources // a list of all sources
var SOURCES = ['openstreetmap', 'openaddresses', 'geonames', 'quattroshapes', 'whosonfirst']; var SOURCES = ['openstreetmap', 'openaddresses', 'geonames', 'whosonfirst'];
/* /*
* A list of alternate names for sources, mostly used to save typing * A list of alternate names for sources, mostly used to save typing
@ -26,7 +26,6 @@ var SOURCE_ALIASES = {
'osm': ['openstreetmap'], 'osm': ['openstreetmap'],
'oa': ['openaddresses'], 'oa': ['openaddresses'],
'gn': ['geonames'], 'gn': ['geonames'],
'qs': ['quattroshapes'],
'wof': ['whosonfirst'] 'wof': ['whosonfirst']
}; };
@ -49,7 +48,6 @@ var LAYERS_BY_SOURCE = {
openstreetmap: [ 'address', 'venue' ], openstreetmap: [ 'address', 'venue' ],
openaddresses: [ 'address' ], openaddresses: [ 'address' ],
geonames: [ 'country', 'region', 'county', 'locality', 'venue' ], geonames: [ 'country', 'region', 'county', 'locality', 'venue' ],
quattroshapes: ['admin0', 'admin1', 'admin2', 'neighborhood', 'locality', 'local_admin'],
whosonfirst: [ 'continent', 'macrocountry', 'country', 'dependency', 'region', whosonfirst: [ 'continent', 'macrocountry', 'country', 'dependency', 'region',
'locality', 'localadmin', 'county', 'macrohood', 'neighbourhood', 'microhood', 'disputed'] 'locality', 'localadmin', 'county', 'macrohood', 'neighbourhood', 'microhood', 'disputed']
}; };
@ -60,9 +58,7 @@ var LAYERS_BY_SOURCE = {
* may have layers that mean the same thing but have a different name * may have layers that mean the same thing but have a different name
*/ */
var LAYER_ALIASES = { var LAYER_ALIASES = {
'coarse': LAYERS_BY_SOURCE.whosonfirst.concat(LAYERS_BY_SOURCE.quattroshapes), 'coarse': LAYERS_BY_SOURCE.whosonfirst
'country': ['country', 'admin0'], // Include both QS and WOF layers for various types of places
'region': ['region', 'admin1'] // Alias layers that include themselves look weird, but do work
}; };
// create a list of all layers by combining each entry from LAYERS_BY_SOURCE // create a list of all layers by combining each entry from LAYERS_BY_SOURCE

14
middleware/confidenceScore.js

@ -84,7 +84,7 @@ function computeConfidenceScore(req, mean, stdev, hit) {
/* /*
* Check for clearly mismatching properties in a result * Check for clearly mismatching properties in a result
* zip code and state (admin1) are currently checked if present * zip code and state (region) are currently checked if present
* *
* @param {object|undefined} text * @param {object|undefined} text
* @param {object} hit * @param {object} hit
@ -95,8 +95,8 @@ function checkForDealBreakers(req, hit) {
return false; return false;
} }
if (check.assigned(req.clean.parsed_text.state) && req.clean.parsed_text.state !== hit.admin1_abbr) { if (check.assigned(req.clean.parsed_text.state) && req.clean.parsed_text.state !== hit.parent.region_a) {
logger.debug('[confidence][deal-breaker]: state !== admin1_abbr'); logger.debug('[confidence][deal-breaker]: state !== region_a');
return true; return true;
} }
@ -210,8 +210,8 @@ function propMatch(textProp, hitProp, expectEnriched) {
* @param {string|number} [hit.address.number] * @param {string|number} [hit.address.number]
* @param {string} [hit.address.street] * @param {string} [hit.address.street]
* @param {string|number} [hit.address.zip] * @param {string|number} [hit.address.zip]
* @param {string} [hit.admin1_abbr] * @param {string} [hit.parent.region_a]
* @param {string} [hit.alpha3] * @param {string} [hit.parent.country_a]
* @returns {number} * @returns {number}
*/ */
function checkAddress(text, hit) { function checkAddress(text, hit) {
@ -222,8 +222,8 @@ function checkAddress(text, hit) {
res += propMatch(text.number, (hit.address ? hit.address.number : null), false); res += propMatch(text.number, (hit.address ? hit.address.number : null), false);
res += propMatch(text.street, (hit.address ? hit.address.street : null), false); res += propMatch(text.street, (hit.address ? hit.address.street : null), false);
res += propMatch(text.postalcode, (hit.address ? hit.address.zip: null), true); res += propMatch(text.postalcode, (hit.address ? hit.address.zip: null), true);
res += propMatch(text.state, hit.admin1_abbr, true); res += propMatch(text.state, hit.parent.region_a, true);
res += propMatch(text.country, hit.alpha3, true); res += propMatch(text.country, hit.parent.country_a, true);
res /= checkCount; res /= checkCount;
} }

21
middleware/dedupe.js

@ -39,8 +39,13 @@ function dedupeResults(req, res, next) {
*/ */
function isDifferent(item1, item2) { function isDifferent(item1, item2) {
try { try {
propMatch(item1, item2, 'admin1_abbr'); if (item1.hasOwnProperty('parent') && item2.hasOwnProperty('parent')) {
propMatch(item1, item2, 'alpha3'); propMatch(item1.parent, item2.parent, 'region_a');
propMatch(item1.parent, item2.parent, 'country');
}
else if (item1.parent !== item2.parent) {
throw new Error('different');
}
if (item1.hasOwnProperty('name') && item2.hasOwnProperty('name')) { if (item1.hasOwnProperty('name') && item2.hasOwnProperty('name')) {
propMatch(item1.name, item2.name, 'default'); propMatch(item1.name, item2.name, 'default');
@ -77,7 +82,17 @@ function isDifferent(item1, item2) {
* @throws {Error} * @throws {Error}
*/ */
function propMatch(item1, item2, prop) { function propMatch(item1, item2, prop) {
if (normalizeString(item1[prop]) !== normalizeString(item2[prop])) { var prop1 = item1[prop];
var prop2 = item2[prop];
// in the case the property is an array (currently only in parent schema)
// simply take the 1st item. this will change in the near future to support multiple hierarchies
if (_.isArray(prop1) && _.isArray(prop2)) {
prop1 = prop1[0];
prop2= prop2[0];
}
if (normalizeString(prop1) !== normalizeString(prop2)) {
throw new Error('different'); throw new Error('different');
} }
} }

2
middleware/localNamingConventions.js

@ -13,7 +13,7 @@ function applyLocalNamingConventions(req, res, next) {
// loop through data items and flip relevant number/street // loop through data items and flip relevant number/street
res.data.filter(function(place){ res.data.filter(function(place){
// only relevant for German addresses // only relevant for German addresses
if( 'DEU' !== place.alpha3 ){ return false; } if( 'DEU' !== place.parent.country_a ){ return false; }
if( !place.hasOwnProperty('address') ){ return false; } if( !place.hasOwnProperty('address') ){ return false; }
if( !place.address.hasOwnProperty('number') ){ return false; } if( !place.address.hasOwnProperty('number') ){ return false; }
if( !place.address.hasOwnProperty('street') ){ return false; } if( !place.address.hasOwnProperty('street') ){ return false; }

71
middleware/renamePlacenames.js

@ -1,4 +1,4 @@
var extend = require('extend'); var _ = require('lodash');
/** /**
- P is a preferred English name - P is a preferred English name
@ -11,56 +11,67 @@ var extend = require('extend');
- A is an abbreviation or code for the place (e.g. "NYC" for New - A is an abbreviation or code for the place (e.g. "NYC" for New
York) York)
*/ */
// config mapping of old names to new ones
var NAME_MAP = { var ADDRESS_PROPS = {
'number': 'housenumber', 'number': 'housenumber',
'zip': 'postalcode', 'zip': 'postalcode',
'alpha3': 'country_a', 'street': 'street'
'admin0': 'country',
'admin1': 'region',
'admin1_abbr': 'region_a',
'admin2': 'county',
'local_admin': 'localadmin',
'neighborhood': 'neighbourhood'
}; };
function setup() { var PARENT_PROPS = [
'country',
'country_id',
'country_a',
'region',
'region_id',
'region_a',
'county',
'county_id',
'county_a',
'localadmin',
'localadmin_id',
'localadmin_a',
'locality',
'locality_id',
'locality_a',
'neighbourhood',
'neighbourhood_id'
];
function setup() {
return renamePlacenames; return renamePlacenames;
} }
function renamePlacenames(req, res, next) { function renamePlacenames(req, res, next) {
// do nothing if no result data set // do nothing if no result data set
if (!res || !res.data) { if (!res || !res.data) {
return next(); return next();
} }
// loop through data items and remap placenames res.data = res.data.map(renameOneRecord);
res.data = res.data.map(renameProperties);
next(); next();
} }
function renameProperties(place) { /*
var newPlace = {}; * Rename the fields in one record
Object.keys(place).forEach(function (property) { */
if (property === 'address') { function renameOneRecord(place) {
extend(newPlace, renameProperties(place[property])); if (place.address) {
} Object.keys(ADDRESS_PROPS).forEach(function (prop) {
else { place[ADDRESS_PROPS[prop]] = place.address[prop];
renameProperty(place, newPlace, property); });
} }
});
return newPlace;
}
function renameProperty(oldObj, newObj, property) { // merge the parent block into the top level object to flatten the structure
if (!oldObj.hasOwnProperty(property)) { if (place.parent) {
return; PARENT_PROPS.forEach(function (prop) {
place[prop] = place.parent[prop];
});
} }
newObj[(NAME_MAP[property] || property)] = oldObj[property]; return place;
} }
module.exports = setup; module.exports = setup;

3
package.json

@ -53,8 +53,7 @@
"pelias-config": "^1.0.1", "pelias-config": "^1.0.1",
"pelias-esclient": "1.0.0", "pelias-esclient": "1.0.0",
"pelias-logger": "^0.0.8", "pelias-logger": "^0.0.8",
"pelias-query": "^5.1.0", "pelias-query": "^6.0.0",
"pelias-schema": "3.0.0",
"pelias-suggester-pipeline": "2.0.4", "pelias-suggester-pipeline": "2.0.4",
"stats-lite": "1.0.3", "stats-lite": "1.0.3",
"through2": "2.0.1" "through2": "2.0.1"

5
public/attribution.md

@ -1,6 +1,7 @@
## Attribution ## Attribution
* Geocoding by [Pelias](https://mapzen.com/pelias) from [Mapzen](https://mapzen.com) Geocoding by [Mapzen Search](https://mapzen.com/projects/search) from [Mapzen](https://mapzen.com). Powered by [Pelias](https://github.com/pelias/pelias) geocoding engine.
* Data from
Data from:
* [OpenStreetMap](http://www.openstreetmap.org/copyright) © OpenStreetMap contributors under [ODbL](http://opendatacommons.org/licenses/odbl/) * [OpenStreetMap](http://www.openstreetmap.org/copyright) © OpenStreetMap contributors under [ODbL](http://opendatacommons.org/licenses/odbl/)
* [Quattroshapes](https://github.com/foursquare/quattroshapes/blob/master/LICENSE.md) licensed under [CC-BY-2.0](https://creativecommons.org/licenses/by/2.0/) * [Quattroshapes](https://github.com/foursquare/quattroshapes/blob/master/LICENSE.md) licensed under [CC-BY-2.0](https://creativecommons.org/licenses/by/2.0/)
* [GeoNames](http://www.geonames.org/) licensed under CC-BY-3.0](https://creativecommons.org/licenses/by/2.0/) * [GeoNames](http://www.geonames.org/) licensed under CC-BY-3.0](https://creativecommons.org/licenses/by/2.0/)

14
query/autocomplete.js

@ -27,14 +27,14 @@ query.score( peliasQuery.view.address('street') );
query.score( peliasQuery.view.address('postcode') ); query.score( peliasQuery.view.address('postcode') );
// admin components // admin components
query.score( peliasQuery.view.admin('alpha3') ); query.score( peliasQuery.view.admin('country') );
query.score( peliasQuery.view.admin('admin0') ); query.score( peliasQuery.view.admin('country_a') );
query.score( peliasQuery.view.admin('admin1') ); query.score( peliasQuery.view.admin('region') );
query.score( peliasQuery.view.admin('admin1_abbr') ); query.score( peliasQuery.view.admin('region_a') );
query.score( peliasQuery.view.admin('admin2') ); query.score( peliasQuery.view.admin('county') );
query.score( peliasQuery.view.admin('local_admin') ); query.score( peliasQuery.view.admin('localadmin') );
query.score( peliasQuery.view.admin('locality') ); query.score( peliasQuery.view.admin('locality') );
query.score( peliasQuery.view.admin('neighborhood') ); query.score( peliasQuery.view.admin('neighbourhood') );
// scoring boost // scoring boost
query.score( views.focus_selected_layers( views.ngrams_strict ) ); query.score( views.focus_selected_layers( views.ngrams_strict ) );

44
query/autocomplete_defaults.js

@ -50,37 +50,37 @@ module.exports = _.merge({}, peliasQuery.defaults, {
'address:postcode:field': 'address.zip', 'address:postcode:field': 'address.zip',
'address:postcode:boost': 2000, 'address:postcode:boost': 2000,
'admin:alpha3:analyzer': 'standard', 'admin:country_a:analyzer': 'standard',
'admin:alpha3:field': 'alpha3', 'admin:country_a:field': 'parent.country_a',
'admin:alpha3:boost': 1000, 'admin:country_a:boost': 1000,
'admin:admin0:analyzer': 'peliasAdmin', 'admin:country:analyzer': 'peliasAdmin',
'admin:admin0:field': 'admin0', 'admin:country:field': 'parent.country',
'admin:admin0:boost': 800, 'admin:country:boost': 800,
'admin:admin1:analyzer': 'peliasAdmin', 'admin:region:analyzer': 'peliasAdmin',
'admin:admin1:field': 'admin1', 'admin:region:field': 'parent.region',
'admin:admin1:boost': 600, 'admin:region:boost': 600,
'admin:admin1_abbr:analyzer': 'peliasAdmin', 'admin:region_a:analyzer': 'peliasAdmin',
'admin:admin1_abbr:field': 'admin1_abbr', 'admin:region_a:field': 'parent.region_a',
'admin:admin1_abbr:boost': 600, 'admin:region_a:boost': 600,
'admin:admin2:analyzer': 'peliasAdmin', 'admin:county:analyzer': 'peliasAdmin',
'admin:admin2:field': 'admin2', 'admin:county:field': 'parent.county',
'admin:admin2:boost': 400, 'admin:county:boost': 400,
'admin:local_admin:analyzer': 'peliasAdmin', 'admin:localadmin:analyzer': 'peliasAdmin',
'admin:local_admin:field': 'local_admin', 'admin:localadmin:field': 'parent.localadmin',
'admin:local_admin:boost': 200, 'admin:localadmin:boost': 200,
'admin:locality:analyzer': 'peliasAdmin', 'admin:locality:analyzer': 'peliasAdmin',
'admin:locality:field': 'locality', 'admin:locality:field': 'parent.locality',
'admin:locality:boost': 200, 'admin:locality:boost': 200,
'admin:neighborhood:analyzer': 'peliasAdmin', 'admin:neighbourhood:analyzer': 'peliasAdmin',
'admin:neighborhood:field': 'neighborhood', 'admin:neighbourhood:field': 'parent.neighbourhood',
'admin:neighborhood:boost': 200, 'admin:neighbourhood:boost': 200,
'popularity:field': 'popularity', 'popularity:field': 'popularity',
'popularity:modifier': 'log1p', 'popularity:modifier': 'log1p',

44
query/reverse_defaults.js

@ -50,37 +50,37 @@ module.exports = _.merge({}, peliasQuery.defaults, {
'address:postcode:field': 'address.zip', 'address:postcode:field': 'address.zip',
'address:postcode:boost': 3, 'address:postcode:boost': 3,
'admin:alpha3:analyzer': 'standard', 'admin:country_a:analyzer': 'standard',
'admin:alpha3:field': 'alpha3', 'admin:country_a:field': 'parent.country_a',
'admin:alpha3:boost': 5, 'admin:country_a:boost': 5,
'admin:admin0:analyzer': 'peliasAdmin', 'admin:country:analyzer': 'peliasAdmin',
'admin:admin0:field': 'admin0', 'admin:country:field': 'parent.country',
'admin:admin0:boost': 4, 'admin:country:boost': 4,
'admin:admin1:analyzer': 'peliasAdmin', 'admin:region:analyzer': 'peliasAdmin',
'admin:admin1:field': 'admin1', 'admin:region:field': 'parent.region',
'admin:admin1:boost': 3, 'admin:region:boost': 3,
'admin:admin1_abbr:analyzer': 'peliasAdmin', 'admin:region_a:analyzer': 'peliasAdmin',
'admin:admin1_abbr:field': 'admin1_abbr', 'admin:region_a:field': 'parent.region_a',
'admin:admin1_abbr:boost': 3, 'admin:region_a:boost': 3,
'admin:admin2:analyzer': 'peliasAdmin', 'admin:county:analyzer': 'peliasAdmin',
'admin:admin2:field': 'admin2', 'admin:county:field': 'parent.county',
'admin:admin2:boost': 2, 'admin:county:boost': 2,
'admin:local_admin:analyzer': 'peliasAdmin', 'admin:localadmin:analyzer': 'peliasAdmin',
'admin:local_admin:field': 'local_admin', 'admin:localadmin:field': 'parent.localadmin',
'admin:local_admin:boost': 1, 'admin:localadmin:boost': 1,
'admin:locality:analyzer': 'peliasAdmin', 'admin:locality:analyzer': 'peliasAdmin',
'admin:locality:field': 'locality', 'admin:locality:field': 'parent.locality',
'admin:locality:boost': 1, 'admin:locality:boost': 1,
'admin:neighborhood:analyzer': 'peliasAdmin', 'admin:neighbourhood:analyzer': 'peliasAdmin',
'admin:neighborhood:field': 'neighborhood', 'admin:neighbourhood:field': 'parent.neighbourhood',
'admin:neighborhood:boost': 1, 'admin:neighbourhood:boost': 1,
'popularity:field': 'popularity', 'popularity:field': 'popularity',
'popularity:modifier': 'log1p', 'popularity:modifier': 'log1p',

14
query/search.js

@ -25,14 +25,14 @@ query.score( peliasQuery.view.address('street') );
query.score( peliasQuery.view.address('postcode') ); query.score( peliasQuery.view.address('postcode') );
// admin components // admin components
query.score( peliasQuery.view.admin('alpha3') ); query.score( peliasQuery.view.admin('country') );
query.score( peliasQuery.view.admin('admin0') ); query.score( peliasQuery.view.admin('country_a') );
query.score( peliasQuery.view.admin('admin1') ); query.score( peliasQuery.view.admin('region') );
query.score( peliasQuery.view.admin('admin1_abbr') ); query.score( peliasQuery.view.admin('region_a') );
query.score( peliasQuery.view.admin('admin2') ); query.score( peliasQuery.view.admin('county') );
query.score( peliasQuery.view.admin('local_admin') ); query.score( peliasQuery.view.admin('localadmin') );
query.score( peliasQuery.view.admin('locality') ); query.score( peliasQuery.view.admin('locality') );
query.score( peliasQuery.view.admin('neighborhood') ); query.score( peliasQuery.view.admin('neighbourhood') );
// non-scoring hard filters // non-scoring hard filters
query.filter( peliasQuery.view.boundary_circle ); query.filter( peliasQuery.view.boundary_circle );

44
query/search_defaults.js

@ -50,37 +50,37 @@ module.exports = _.merge({}, peliasQuery.defaults, {
'address:postcode:field': 'address.zip', 'address:postcode:field': 'address.zip',
'address:postcode:boost': 20, 'address:postcode:boost': 20,
'admin:alpha3:analyzer': 'standard', 'admin:country_a:analyzer': 'standard',
'admin:alpha3:field': 'alpha3', 'admin:country_a:field': 'parent.country_a',
'admin:alpha3:boost': 5, 'admin:country_a:boost': 5,
'admin:admin0:analyzer': 'peliasAdmin', 'admin:country:analyzer': 'peliasAdmin',
'admin:admin0:field': 'admin0', 'admin:country:field': 'parent.country',
'admin:admin0:boost': 4, 'admin:country:boost': 4,
'admin:admin1:analyzer': 'peliasAdmin', 'admin:region:analyzer': 'peliasAdmin',
'admin:admin1:field': 'admin1', 'admin:region:field': 'parent.region',
'admin:admin1:boost': 3, 'admin:region:boost': 3,
'admin:admin1_abbr:analyzer': 'peliasAdmin', 'admin:region_a:analyzer': 'peliasAdmin',
'admin:admin1_abbr:field': 'admin1_abbr', 'admin:region_a:field': 'parent.region_a',
'admin:admin1_abbr:boost': 3, 'admin:region_a:boost': 3,
'admin:admin2:analyzer': 'peliasAdmin', 'admin:county:analyzer': 'peliasAdmin',
'admin:admin2:field': 'admin2', 'admin:county:field': 'parent.county',
'admin:admin2:boost': 2, 'admin:county:boost': 2,
'admin:local_admin:analyzer': 'peliasAdmin', 'admin:localadmin:analyzer': 'peliasAdmin',
'admin:local_admin:field': 'local_admin', 'admin:localadmin:field': 'parent.localadmin',
'admin:local_admin:boost': 1, 'admin:localadmin:boost': 1,
'admin:locality:analyzer': 'peliasAdmin', 'admin:locality:analyzer': 'peliasAdmin',
'admin:locality:field': 'locality', 'admin:locality:field': 'parent.locality',
'admin:locality:boost': 1, 'admin:locality:boost': 1,
'admin:neighborhood:analyzer': 'peliasAdmin', 'admin:neighbourhood:analyzer': 'peliasAdmin',
'admin:neighborhood:field': 'neighborhood', 'admin:neighbourhood:field': 'parent.neighbourhood',
'admin:neighborhood:boost': 1, 'admin:neighbourhood:boost': 1,
'popularity:field': 'popularity', 'popularity:field': 'popularity',
'popularity:modifier': 'log1p', 'popularity:modifier': 'log1p',

27
query/text_parser.js

@ -1,6 +1,20 @@
var logger = require('pelias-logger').get('api'); var logger = require('pelias-logger').get('api');
var adminFields = require('../helper/adminFields')();
/*
This list should only contain admin fields we are comfortable matching in the case
when we can't identify parts of an address. This shouldn't contain fields like country_a
or postalcode because we should only try to match those when we're sure that's what they are.
*/
var adminFields = [
'country',
'region',
'region_a',
'county',
'localadmin',
'locality',
'neighbourhood'
];
/** /**
@todo: refactor me @todo: refactor me
@ -48,17 +62,17 @@ function addParsedVariablesToQueryVariables( parsed_text, vs ){
// city // city
if( parsed_text.hasOwnProperty('city') ){ if( parsed_text.hasOwnProperty('city') ){
vs.var( 'input:admin2', parsed_text.city ); vs.var( 'input:county', parsed_text.city );
} }
// state // state
if( parsed_text.hasOwnProperty('state') ){ if( parsed_text.hasOwnProperty('state') ){
vs.var( 'input:admin1_abbr', parsed_text.state ); vs.var( 'input:region_a', parsed_text.state );
} }
// country // country
if( parsed_text.hasOwnProperty('country') ){ if( parsed_text.hasOwnProperty('country') ){
vs.var( 'input:alpha3', parsed_text.country ); vs.var( 'input:country_a', parsed_text.country );
} }
// ==== deal with the 'leftover' components ==== // ==== deal with the 'leftover' components ====
@ -76,11 +90,10 @@ function addParsedVariablesToQueryVariables( parsed_text, vs ){
// if we have 'leftovers' then assign them to any fields which // if we have 'leftovers' then assign them to any fields which
// currently don't have a value assigned. // currently don't have a value assigned.
if( leftoversString.length ){ if( leftoversString.length ){
var unmatchedAdminFields = adminFields.slice();
// cycle through fields and set fields which // cycle through fields and set fields which
// are still currently unset // are still currently unset
unmatchedAdminFields.forEach( function( key ){ adminFields.forEach( function( key ){
if( !vs.isset( 'input:' + key ) ){ if( !vs.isset( 'input:' + key ) ){
vs.var( 'input:' + key, leftoversString ); vs.var( 'input:' + key, leftoversString );
} }

7
test/ciao/reverse/layers_alias_coarse.coffee

@ -41,10 +41,5 @@ json.geocoding.query.layers.should.eql [ "continent",
"macrohood", "macrohood",
"neighbourhood", "neighbourhood",
"microhood", "microhood",
"disputed", "disputed"
"admin0",
"admin1",
"admin2",
"neighborhood",
"local_admin"
] ]

2
test/ciao/reverse/layers_invalid.coffee

@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors #? expected errors
should.exist json.geocoding.errors should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,country,region,address,venue,county,locality,admin0,admin1,admin2,neighborhood,local_admin,continent,macrocountry,dependency,localadmin,macrohood,neighbourhood,microhood,disputed' ] json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,country,region,county,locality,continent,macrocountry,dependency,localadmin,macrohood,neighbourhood,microhood,disputed' ]
#? expected warnings #? expected warnings
should.not.exist json.geocoding.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 #? expected errors
should.exist json.geocoding.errors should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,country,region,address,venue,county,locality,admin0,admin1,admin2,neighborhood,local_admin,continent,macrocountry,dependency,localadmin,macrohood,neighbourhood,microhood,disputed' ] json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,country,region,county,locality,continent,macrocountry,dependency,localadmin,macrohood,neighbourhood,microhood,disputed' ]
#? expected warnings #? expected warnings
should.not.exist json.geocoding.warnings should.not.exist json.geocoding.warnings

2
test/ciao/reverse/layers_multiple.coffee

@ -30,4 +30,4 @@ should.not.exist json.geocoding.warnings
#? inputs #? inputs
json.geocoding.query['size'].should.eql 10 json.geocoding.query['size'].should.eql 10
json.geocoding.query.layers.should.eql ["country","admin0","region","admin1"] json.geocoding.query.layers.should.eql ["country","region"]

2
test/ciao/reverse/layers_single.coffee

@ -30,4 +30,4 @@ should.not.exist json.geocoding.warnings
#? inputs #? inputs
json.geocoding.query['size'].should.eql 10 json.geocoding.query['size'].should.eql 10
json.geocoding.query.layers.should.eql ["country","admin0"] json.geocoding.query.layers.should.eql ["country"]

2
test/ciao/reverse/sources_invalid.coffee

@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors #? expected errors
should.exist json.geocoding.errors should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notasource\' is an invalid sources parameter. Valid options: osm,oa,gn,qs,wof,openstreetmap,openaddresses,geonames,quattroshapes,whosonfirst' ] json.geocoding.errors.should.eql [ '\'notasource\' is an invalid sources parameter. Valid options: osm,oa,gn,wof,openstreetmap,openaddresses,geonames,whosonfirst' ]
#? expected warnings #? expected warnings
should.not.exist json.geocoding.warnings should.not.exist json.geocoding.warnings

6
test/ciao/reverse/sources_layers_invalid_combo.coffee

@ -1,6 +1,6 @@
#> sources and layers specified (invalid combo) #> sources and layers specified (invalid combo)
path: '/v1/reverse?point.lat=1&point.lon=2&sources=quattroshapes&layers=address' path: '/v1/reverse?point.lat=1&point.lon=2&sources=whosonfirst&layers=address'
#? 200 ok #? 200 ok
response.statusCode.should.be.equal 400 response.statusCode.should.be.equal 400
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors #? expected errors
should.exist json.geocoding.errors should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'You have specified both the `sources` and `layers` parameters in a combination that will return no results: the quattroshapes source has nothing in the address layer' ] json.geocoding.errors.should.eql [ 'You have specified both the `sources` and `layers` parameters in a combination that will return no results: the whosonfirst source has nothing in the address layer' ]
#? expected warnings #? expected warnings
should.not.exist json.geocoding.warnings should.not.exist json.geocoding.warnings
@ -32,4 +32,4 @@ should.not.exist json.geocoding.warnings
#? inputs #? inputs
json.geocoding.query['size'].should.eql 10 json.geocoding.query['size'].should.eql 10
json.geocoding.query.layers.should.eql ["address"] json.geocoding.query.layers.should.eql ["address"]
json.geocoding.query.sources.should.eql ["quattroshapes"] json.geocoding.query.sources.should.eql ["whosonfirst"]

7
test/ciao/search/layers_alias_coarse.coffee

@ -42,10 +42,5 @@ json.geocoding.query.layers.should.eql [ "continent",
"macrohood", "macrohood",
"neighbourhood", "neighbourhood",
"microhood", "microhood",
"disputed", "disputed"
"admin0",
"admin1",
"admin2",
"neighborhood",
"local_admin"
] ]

2
test/ciao/search/layers_invalid.coffee

@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors #? expected errors
should.exist json.geocoding.errors should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,country,region,address,venue,county,locality,admin0,admin1,admin2,neighborhood,local_admin,continent,macrocountry,dependency,localadmin,macrohood,neighbourhood,microhood,disputed' ] json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,country,region,county,locality,continent,macrocountry,dependency,localadmin,macrohood,neighbourhood,microhood,disputed' ]
#? expected warnings #? expected warnings
should.not.exist json.geocoding.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 #? expected errors
should.exist json.geocoding.errors should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,country,region,address,venue,county,locality,admin0,admin1,admin2,neighborhood,local_admin,continent,macrocountry,dependency,localadmin,macrohood,neighbourhood,microhood,disputed' ] json.geocoding.errors.should.eql [ '\'notlayer\' is an invalid layers parameter. Valid options: coarse,address,venue,country,region,county,locality,continent,macrocountry,dependency,localadmin,macrohood,neighbourhood,microhood,disputed' ]
#? expected warnings #? expected warnings
should.not.exist json.geocoding.warnings should.not.exist json.geocoding.warnings

2
test/ciao/search/layers_multiple.coffee

@ -31,4 +31,4 @@ should.not.exist json.geocoding.warnings
#? inputs #? inputs
json.geocoding.query['text'].should.eql 'a' json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10 json.geocoding.query['size'].should.eql 10
json.geocoding.query.layers.should.eql ["country","admin0","region","admin1"] json.geocoding.query.layers.should.eql ["country","region"]

2
test/ciao/search/layers_single.coffee

@ -31,4 +31,4 @@ should.not.exist json.geocoding.warnings
#? inputs #? inputs
json.geocoding.query['text'].should.eql 'a' json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10 json.geocoding.query['size'].should.eql 10
json.geocoding.query.layers.should.eql ["country","admin0"] json.geocoding.query.layers.should.eql ["country"]

2
test/ciao/search/sources_invalid.coffee

@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors #? expected errors
should.exist json.geocoding.errors should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ '\'notasource\' is an invalid sources parameter. Valid options: osm,oa,gn,qs,wof,openstreetmap,openaddresses,geonames,quattroshapes,whosonfirst' ] json.geocoding.errors.should.eql [ '\'notasource\' is an invalid sources parameter. Valid options: osm,oa,gn,wof,openstreetmap,openaddresses,geonames,whosonfirst' ]
#? expected warnings #? expected warnings
should.not.exist json.geocoding.warnings should.not.exist json.geocoding.warnings

6
test/ciao/search/sources_layers_invalid_combo.coffee

@ -1,6 +1,6 @@
#> sources and layers specified (invalid combo) #> sources and layers specified (invalid combo)
path: '/v1/search?text=a&sources=quattroshapes&layers=address' path: '/v1/search?text=a&sources=whosonfirst&layers=address'
#? 200 ok #? 200 ok
response.statusCode.should.be.equal 400 response.statusCode.should.be.equal 400
@ -24,7 +24,7 @@ json.features.should.be.instanceof Array
#? expected errors #? expected errors
should.exist json.geocoding.errors should.exist json.geocoding.errors
json.geocoding.errors.should.eql [ 'You have specified both the `sources` and `layers` parameters in a combination that will return no results: the quattroshapes source has nothing in the address layer' ] json.geocoding.errors.should.eql [ 'You have specified both the `sources` and `layers` parameters in a combination that will return no results: the whosonfirst source has nothing in the address layer' ]
#? expected warnings #? expected warnings
should.not.exist json.geocoding.warnings should.not.exist json.geocoding.warnings
@ -33,5 +33,5 @@ should.not.exist json.geocoding.warnings
json.geocoding.query['text'].should.eql 'a' json.geocoding.query['text'].should.eql 'a'
json.geocoding.query['size'].should.eql 10 json.geocoding.query['size'].should.eql 10
json.geocoding.query.layers.should.eql ["address"] json.geocoding.query.layers.should.eql ["address"]
json.geocoding.query.sources.should.eql ["quattroshapes"] json.geocoding.query.sources.should.eql ["whosonfirst"]
should.not.exist json.geocoding.query['type'] should.not.exist json.geocoding.query['type']

16
test/unit/controller/search.js

@ -50,9 +50,11 @@ module.exports.tests.functional_success = function(test, common) {
_id: 'myid1', _id: 'myid1',
_score: 10, _score: 10,
_type: 'mytype1', _type: 'mytype1',
admin0: 'country1', parent: {
admin1: 'state1', country: 'country1',
admin2: 'city1', region: 'state1',
county: 'city1'
},
center_point: { lat: 100.1, lon: -50.5 }, center_point: { lat: 100.1, lon: -50.5 },
name: { default: 'test name1' }, name: { default: 'test name1' },
value: 1 value: 1
@ -61,9 +63,11 @@ module.exports.tests.functional_success = function(test, common) {
_id: 'myid2', _id: 'myid2',
_score: 20, _score: 20,
_type: 'mytype2', _type: 'mytype2',
admin0: 'country2', parent: {
admin1: 'state2', country: 'country2',
admin2: 'city2', region: 'state2',
county: 'city2'
},
center_point: { lat: 100.2, lon: -51.5 }, center_point: { lat: 100.2, lon: -51.5 },
name: { default: 'test name2' }, name: { default: 'test name2' },
value: 2 value: 2

14
test/unit/fixture/autocomplete_linguistic_with_admin.js

@ -20,7 +20,7 @@ module.exports = {
'should': [ 'should': [
{ {
'match': { 'match': {
'admin0': { 'parent.country': {
'analyzer': 'peliasAdmin', 'analyzer': 'peliasAdmin',
'boost': 800, 'boost': 800,
'query': 'three' 'query': 'three'
@ -29,7 +29,7 @@ module.exports = {
}, },
{ {
'match': { 'match': {
'admin1': { 'parent.region': {
'analyzer': 'peliasAdmin', 'analyzer': 'peliasAdmin',
'boost': 600, 'boost': 600,
'query': 'three' 'query': 'three'
@ -38,7 +38,7 @@ module.exports = {
}, },
{ {
'match': { 'match': {
'admin1_abbr': { 'parent.region_a': {
'analyzer': 'peliasAdmin', 'analyzer': 'peliasAdmin',
'boost': 600, 'boost': 600,
'query': 'three' 'query': 'three'
@ -47,7 +47,7 @@ module.exports = {
}, },
{ {
'match': { 'match': {
'admin2': { 'parent.county': {
'analyzer': 'peliasAdmin', 'analyzer': 'peliasAdmin',
'boost': 400, 'boost': 400,
'query': 'three' 'query': 'three'
@ -56,7 +56,7 @@ module.exports = {
}, },
{ {
'match': { 'match': {
'local_admin': { 'parent.localadmin': {
'analyzer': 'peliasAdmin', 'analyzer': 'peliasAdmin',
'boost': 200, 'boost': 200,
'query': 'three' 'query': 'three'
@ -65,7 +65,7 @@ module.exports = {
}, },
{ {
'match': { 'match': {
'locality': { 'parent.locality': {
'analyzer': 'peliasAdmin', 'analyzer': 'peliasAdmin',
'boost': 200, 'boost': 200,
'query': 'three' 'query': 'three'
@ -74,7 +74,7 @@ module.exports = {
}, },
{ {
'match': { 'match': {
'neighborhood': { 'parent.neighbourhood': {
'analyzer': 'peliasAdmin', 'analyzer': 'peliasAdmin',
'boost': 200, 'boost': 200,
'query': 'three' 'query': 'three'

38
test/unit/fixture/dedupe_elasticsearch_nonascii_results.js

@ -7,9 +7,11 @@ module.exports = [
'name': { 'name': {
'default': '万里长城万里长城' 'default': '万里长城万里长城'
}, },
'country_a': 'CHN', 'parent': {
'country': 'China', 'country_a': 'CHN',
'region': 'Beijing', 'country': 'China',
'region': 'Beijing'
},
'confidence': 0.733 'confidence': 0.733
}, },
{ {
@ -20,9 +22,11 @@ module.exports = [
'name': { 'name': {
'default': '万里长城' 'default': '万里长城'
}, },
'country_a': 'CHN', 'parent': {
'country': 'China', 'country_a': 'CHN',
'region': 'Beijing', 'country': 'China',
'region': 'Beijing'
},
'confidence': 0.733 'confidence': 0.733
}, },
{ {
@ -33,12 +37,14 @@ module.exports = [
'name': { 'name': {
'default': '万里花' 'default': '万里花'
}, },
'country_a': 'JPN', 'parent': {
'country': 'Japan', 'country_a': 'JPN',
'region': 'Tokyo', 'country': 'Japan',
'county': '豊島区', 'region': 'Tokyo',
'locality': 'Tokyo', 'county': '豊島区',
'neighbourhood': '2丁目', 'locality': 'Tokyo',
'neighbourhood': '2丁目'
},
'confidence': 0.646 'confidence': 0.646
}, },
{ {
@ -53,9 +59,11 @@ module.exports = [
'street': 'S308', 'street': 'S308',
'postalcode': '312044' 'postalcode': '312044'
}, },
'country_a': 'CHN', 'parent': {
'country': 'China', 'country_a': 'CHN',
'region': 'Zhejiang', 'country': 'China',
'region': 'Zhejiang'
},
'confidence': 0.646 'confidence': 0.646
} }
]; ];

204
test/unit/fixture/dedupe_elasticsearch_results.js

@ -5,22 +5,24 @@ module.exports = [
'lat': 40.039265 'lat': 40.039265
}, },
'address': {}, 'address': {},
'local_admin': 'East Lampeter', 'parent': {
'admin1_abbr': 'PA', 'localadmin': 'East Lampeter',
'region_a': 'PA',
'region': 'Pennsylvania',
'locality': 'Smoketown',
'country_a': 'USA',
'county': 'Lancaster County',
'country': 'United States',
'neighbourhood': 'Greenland'
},
'name': { 'name': {
'default': 'East Lampeter High School' 'default': 'East Lampeter High School'
}, },
'admin1': 'Pennsylvania',
'locality': 'Smoketown',
'alpha3': 'USA',
'admin2': 'Lancaster County',
'admin0': 'United States',
'neighborhood': 'Greenland',
'category': [ 'category': [
'education' 'education'
], ],
'_id': '357321757', '_id': '357321757',
'_type': 'osmnode', '_type': 'venue',
'_score': 1.2367082, '_score': 1.2367082,
'confidence': 0.879 'confidence': 0.879
}, },
@ -30,22 +32,24 @@ module.exports = [
'lat': 40.039265 'lat': 40.039265
}, },
'address': {}, 'address': {},
'local_admin': 'East Lampeter', 'parent': {
'admin1_abbr': 'PA', 'localadmin': 'East Lampeter',
'region_a': 'PA',
'region': 'Pennsylvania',
'locality': 'Smoketown',
'country_a': 'USA',
'county': 'Lancaster County',
'country': 'United States',
'neighbourhood': 'Greenland'
},
'name': { 'name': {
'default': 'East Lampeter, High-School' 'default': 'East Lampeter, High-School'
}, },
'admin1': 'Pennsylvania',
'locality': 'Smoketown',
'alpha3': 'USA',
'admin2': 'Lancaster County',
'admin0': 'United States',
'neighborhood': 'Greenland',
'category': [ 'category': [
'education' 'education'
], ],
'_id': '357321757', '_id': '357321757',
'_type': 'osmnode', '_type': 'venue',
'_score': 1.2367082, '_score': 1.2367082,
'confidence': 0.879 'confidence': 0.879
}, },
@ -55,17 +59,19 @@ module.exports = [
'lat': 39.99288 'lat': 39.99288
}, },
'address': {}, 'address': {},
'local_admin': 'West Lampeter', 'parent': {
'admin1_abbr': 'PA', 'localadmin': 'West Lampeter',
'region_a': 'PA',
'region': 'Pennsylvania',
'locality': 'Lampeter',
'country_a': 'USA',
'county': 'Lancaster County',
'country': 'United States',
'neighbourhood': 'Wheatland Mills'
},
'name': { 'name': {
'default': 'Lampeter-Strasburg High School' 'default': 'Lampeter-Strasburg High School'
}, },
'admin1': 'Pennsylvania',
'locality': 'Lampeter',
'alpha3': 'USA',
'admin2': 'Lancaster County',
'admin0': 'United States',
'neighborhood': 'Wheatland Mills',
'category': [ 'category': [
'education' 'education'
], ],
@ -80,17 +86,19 @@ module.exports = [
'lat': 40.03927 'lat': 40.03927
}, },
'address': {}, 'address': {},
'local_admin': 'East Lampeter', 'parent': {
'admin1_abbr': 'PA', 'localadmin': 'East Lampeter',
'region_a': 'PA',
'region': 'Pennsylvania',
'locality': 'Smoketown',
'country_a': 'USA',
'county': 'Lancaster County',
'country': 'United States',
'neighbourhood': 'Greenland'
},
'name': { 'name': {
'default': 'East Lampeter High School' 'default': 'East Lampeter High School'
}, },
'admin1': 'Pennsylvania',
'locality': 'Smoketown',
'alpha3': 'USA',
'admin2': 'Lancaster County',
'admin0': 'United States',
'neighborhood': 'Greenland',
'category': [ 'category': [
'education' 'education'
], ],
@ -105,22 +113,24 @@ module.exports = [
'lat': 39.992877 'lat': 39.992877
}, },
'address': {}, 'address': {},
'local_admin': 'West Lampeter', 'parent': {
'admin1_abbr': 'PA', 'region': 'Pennsylvania',
'locality': 'Lampeter',
'country_a': 'USA',
'county': 'Lancaster County',
'country': 'United States',
'neighbourhood': 'Wheatland Mills',
'localadmin': 'West Lampeter',
'region_a': 'PA'
},
'name': { 'name': {
'default': 'Lampeter-Strasburg High School' 'default': 'Lampeter-Strasburg High School'
}, },
'admin1': 'Pennsylvania',
'locality': 'Lampeter',
'alpha3': 'USA',
'admin2': 'Lancaster County',
'admin0': 'United States',
'neighborhood': 'Wheatland Mills',
'category': [ 'category': [
'education' 'education'
], ],
'_id': '357294404', '_id': '357294404',
'_type': 'osmnode', '_type': 'venue',
'_score': 1.2367082, '_score': 1.2367082,
'confidence': 0.879 'confidence': 0.879
}, },
@ -130,22 +140,24 @@ module.exports = [
'lat': 40.038987 'lat': 40.038987
}, },
'address': {}, 'address': {},
'local_admin': 'East Lampeter', 'parent': {
'admin1_abbr': 'PA', 'region': 'Pennsylvania',
'locality': 'Smoketown',
'country_a': 'USA',
'county': 'Lancaster County',
'country': 'United States',
'neighbourhood': 'Greenland',
'localadmin': 'East Lampeter',
'region_a': 'PA'
},
'name': { 'name': {
'default': 'East Lampeter School' 'default': 'East Lampeter School'
}, },
'admin1': 'Pennsylvania',
'locality': 'Smoketown',
'alpha3': 'USA',
'admin2': 'Lancaster County',
'admin0': 'United States',
'neighborhood': 'Greenland',
'category': [ 'category': [
'education' 'education'
], ],
'_id': '357283977', '_id': '357283977',
'_type': 'osmnode', '_type': 'venue',
'_score': 1.1036991, '_score': 1.1036991,
'confidence': 0.664 'confidence': 0.664
}, },
@ -155,17 +167,19 @@ module.exports = [
'lat': 40.03899 'lat': 40.03899
}, },
'address': {}, 'address': {},
'local_admin': 'East Lampeter', 'parent': {
'admin1_abbr': 'PA', 'region': 'Pennsylvania',
'locality': 'Smoketown',
'country_a': 'USA',
'county': 'Lancaster County',
'country': 'United States',
'neighbourhood': 'Greenland',
'localadmin': 'East Lampeter',
'region_a': 'PA'
},
'name': { 'name': {
'default': 'East Lampeter School' 'default': 'East Lampeter School'
}, },
'admin1': 'Pennsylvania',
'locality': 'Smoketown',
'alpha3': 'USA',
'admin2': 'Lancaster County',
'admin0': 'United States',
'neighborhood': 'Greenland',
'category': [ 'category': [
'education' 'education'
], ],
@ -180,21 +194,23 @@ module.exports = [
'lat': 38.762788 'lat': 38.762788
}, },
'address': {}, 'address': {},
'local_admin': 'Polk', 'parent': {
'admin1_abbr': 'MO', 'region': 'Missouri',
'locality': 'Strasburg',
'country_a': 'USA',
'county': 'Cass County',
'country': 'United States',
'localadmin': 'Polk',
'region_a': 'MO'
},
'name': { 'name': {
'default': 'Strasburg School' 'default': 'Strasburg School'
}, },
'admin1': 'Missouri',
'locality': 'Strasburg',
'alpha3': 'USA',
'admin2': 'Cass County',
'admin0': 'United States',
'category': [ 'category': [
'education' 'education'
], ],
'_id': '358058986', '_id': '358058986',
'_type': 'osmnode', '_type': 'venue',
'_score': 1.0492544, '_score': 1.0492544,
'confidence': 0.658 'confidence': 0.658
}, },
@ -204,16 +220,18 @@ module.exports = [
'lat': 38.98445 'lat': 38.98445
}, },
'address': {}, 'address': {},
'admin1_abbr': 'VA',
'name': { 'name': {
'default': 'Strasburg High School' 'default': 'Strasburg High School'
}, },
'admin1': 'Virginia', 'parent': {
'locality': 'Strasburg', 'region_a': 'VA',
'alpha3': 'USA', 'region': 'Virginia',
'admin2': 'Shenandoah County', 'locality': 'Strasburg',
'admin0': 'United States', 'country_a': 'USA',
'neighborhood': 'Strasburg Junction', 'county': 'Shenandoah County',
'country': 'United States',
'neighbourhood': 'Strasburg Junction'
},
'category': [ 'category': [
'education' 'education'
], ],
@ -228,16 +246,18 @@ module.exports = [
'lat': 46.13427 'lat': 46.13427
}, },
'address': {}, 'address': {},
'local_admin': 'Strasburg',
'admin1_abbr': 'ND',
'name': { 'name': {
'default': 'Strasburg High School' 'default': 'Strasburg High School'
}, },
'admin1': 'North Dakota', 'parent': {
'locality': 'Strasburg', 'localadmin': 'Strasburg',
'alpha3': 'USA', 'region_a': 'ND',
'admin2': 'Emmons County', 'region': 'North Dakota',
'admin0': 'United States', 'locality': 'Strasburg',
'country_a': 'USA',
'county': 'Emmons County',
'country': 'United States'
},
'category': [ 'category': [
'education' 'education'
], ],
@ -252,22 +272,24 @@ module.exports = [
'lat': 40.597578 'lat': 40.597578
}, },
'address': {}, 'address': {},
'local_admin': 'Franklin',
'admin1_abbr': 'OH',
'name': { 'name': {
'default': 'Strasburg High School' 'default': 'Strasburg High School'
}, },
'admin1': 'Ohio', 'parent': {
'locality': 'Strasburg', 'localadmin': 'Franklin',
'alpha3': 'USA', 'region_a': 'OH',
'admin2': 'Tuscarawas County', 'region': 'Ohio',
'admin0': 'United States', 'locality': 'Strasburg',
'country_a': 'USA',
'county': 'Tuscarawas County',
'country': 'United States'
},
'category': [ 'category': [
'education' 'education'
], ],
'_id': '356646971', '_id': '356646971',
'_type': 'osmway', '_type': 'venue',
'_score': 0.9724125, '_score': 0.9724125,
'confidence': 0.649 'confidence': 0.649
} }
]; ];

2
test/unit/fixture/reverse_with_boundary_country.js

@ -8,7 +8,7 @@ module.exports = {
'must': [ 'must': [
{ {
'match': { 'match': {
'alpha3': { 'parent.country_a': {
'analyzer': 'standard', 'analyzer': 'standard',
'query': 'ABC' 'query': 'ABC'
} }

2
test/unit/fixture/search_boundary_country.js

@ -7,7 +7,7 @@ module.exports = {
'must': [ 'must': [
{ {
'match': { 'match': {
'alpha3': { 'parent.country_a': {
'analyzer': 'standard', 'analyzer': 'standard',
'query': 'ABC' 'query': 'ABC'
} }

48
test/unit/fixture/search_full_address.js

@ -109,55 +109,55 @@ module.exports = {
} }
}, { }, {
'match': { 'match': {
'alpha3': { 'parent.country': {
'query': 'USA', 'query': 'new york',
'boost': vs['admin:alpha3:boost'], 'boost': vs['admin:country:boost'],
'analyzer': vs['admin:alpha3:analyzer'] 'analyzer': vs['admin:country:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'admin0': { 'parent.country_a': {
'query': 'new york', 'query': 'USA',
'boost': vs['admin:admin0:boost'], 'boost': vs['admin:country_a:boost'],
'analyzer': vs['admin:admin0:analyzer'] 'analyzer': vs['admin:country_a:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'admin1': { 'parent.region': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:admin1:boost'], 'boost': vs['admin:region:boost'],
'analyzer': vs['admin:admin1:analyzer'] 'analyzer': vs['admin:region:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'admin1_abbr': { 'parent.region_a': {
'query': 'NY', 'query': 'NY',
'boost': vs['admin:admin1_abbr:boost'], 'boost': vs['admin:region_a:boost'],
'analyzer': vs['admin:admin1_abbr:analyzer'] 'analyzer': vs['admin:region_a:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'admin2': { 'parent.county': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:admin2:boost'], 'boost': vs['admin:county:boost'],
'analyzer': vs['admin:admin2:analyzer'] 'analyzer': vs['admin:county:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'local_admin': { 'parent.localadmin': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:local_admin:boost'], 'boost': vs['admin:localadmin:boost'],
'analyzer': vs['admin:local_admin:analyzer'] 'analyzer': vs['admin:localadmin:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'locality': { 'parent.locality': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:locality:boost'], 'boost': vs['admin:locality:boost'],
'analyzer': vs['admin:locality:analyzer'] 'analyzer': vs['admin:locality:analyzer']
@ -165,10 +165,10 @@ module.exports = {
} }
}, { }, {
'match': { 'match': {
'neighborhood': { 'parent.neighbourhood': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:neighborhood:boost'], 'boost': vs['admin:neighbourhood:boost'],
'analyzer': vs['admin:neighborhood:analyzer'] 'analyzer': vs['admin:neighbourhood:analyzer']
} }
} }
}] }]

38
test/unit/fixture/search_partial_address.js

@ -85,47 +85,47 @@ module.exports = {
} }
},{ },{
'match': { 'match': {
'admin0': { 'parent.country': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:admin0:boost'], 'boost': vs['admin:country:boost'],
'analyzer': vs['admin:admin0:analyzer'] 'analyzer': vs['admin:country:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'admin1': { 'parent.region': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:admin1:boost'], 'boost': vs['admin:region:boost'],
'analyzer': vs['admin:admin1:analyzer'] 'analyzer': vs['admin:region:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'admin1_abbr': { 'parent.region_a': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:admin1_abbr:boost'], 'boost': vs['admin:region_a:boost'],
'analyzer': vs['admin:admin1_abbr:analyzer'] 'analyzer': vs['admin:region_a:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'admin2': { 'parent.county': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:admin2:boost'], 'boost': vs['admin:county:boost'],
'analyzer': vs['admin:admin2:analyzer'] 'analyzer': vs['admin:county:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'local_admin': { 'parent.localadmin': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:local_admin:boost'], 'boost': vs['admin:localadmin:boost'],
'analyzer': vs['admin:local_admin:analyzer'] 'analyzer': vs['admin:localadmin:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'locality': { 'parent.locality': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:locality:boost'], 'boost': vs['admin:locality:boost'],
'analyzer': vs['admin:locality:analyzer'] 'analyzer': vs['admin:locality:analyzer']
@ -133,10 +133,10 @@ module.exports = {
} }
}, { }, {
'match': { 'match': {
'neighborhood': { 'parent.neighbourhood': {
'query': 'new york', 'query': 'new york',
'boost': vs['admin:neighborhood:boost'], 'boost': vs['admin:neighbourhood:boost'],
'analyzer': vs['admin:neighborhood:analyzer'] 'analyzer': vs['admin:neighbourhood:analyzer']
} }
} }
}] }]

38
test/unit/fixture/search_regions_address.js

@ -101,47 +101,47 @@ module.exports = {
} }
}, { }, {
'match': { 'match': {
'admin0': { 'parent.country': {
'query': 'manhattan', 'query': 'manhattan',
'boost': vs['admin:admin0:boost'], 'boost': vs['admin:country:boost'],
'analyzer': vs['admin:admin0:analyzer'] 'analyzer': vs['admin:country:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'admin1': { 'parent.region': {
'query': 'manhattan', 'query': 'manhattan',
'boost': vs['admin:admin1:boost'], 'boost': vs['admin:region:boost'],
'analyzer': vs['admin:admin1:analyzer'] 'analyzer': vs['admin:region:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'admin1_abbr': { 'parent.region_a': {
'query': 'NY', 'query': 'NY',
'boost': vs['admin:admin1_abbr:boost'], 'boost': vs['admin:region_a:boost'],
'analyzer': vs['admin:admin1_abbr:analyzer'] 'analyzer': vs['admin:region_a:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'admin2': { 'parent.county': {
'query': 'manhattan', 'query': 'manhattan',
'boost': vs['admin:admin2:boost'], 'boost': vs['admin:county:boost'],
'analyzer': vs['admin:admin2:analyzer'] 'analyzer': vs['admin:county:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'local_admin': { 'parent.localadmin': {
'query': 'manhattan', 'query': 'manhattan',
'boost': vs['admin:local_admin:boost'], 'boost': vs['admin:localadmin:boost'],
'analyzer': vs['admin:local_admin:analyzer'] 'analyzer': vs['admin:localadmin:analyzer']
} }
} }
}, { }, {
'match': { 'match': {
'locality': { 'parent.locality': {
'query': 'manhattan', 'query': 'manhattan',
'boost': vs['admin:locality:boost'], 'boost': vs['admin:locality:boost'],
'analyzer': vs['admin:locality:analyzer'] 'analyzer': vs['admin:locality:analyzer']
@ -149,10 +149,10 @@ module.exports = {
} }
}, { }, {
'match': { 'match': {
'neighborhood': { 'parent.neighbourhood': {
'query': 'manhattan', 'query': 'manhattan',
'boost': vs['admin:neighborhood:boost'], 'boost': vs['admin:neighbourhood:boost'],
'analyzer': vs['admin:neighborhood:analyzer'] 'analyzer': vs['admin:neighbourhood:analyzer']
} }
} }
}] }]

84
test/unit/helper/adminFields.js

@ -1,84 +0,0 @@
var adminFields = require('../../../helper/adminFields');
module.exports.tests = {};
module.exports.tests.interface = function(test, common) {
test('validate fields', function(t) {
t.assert(adminFields instanceof Function, 'adminFields is a function');
t.assert(adminFields() instanceof Array, 'adminFields() returns an array');
t.assert(adminFields().length > 0, 'adminFields array is not empty');
t.end();
});
};
module.exports.tests.lookupExistance = function(test, common) {
test('all expected fields in schema', function(t) {
var expectedFields = [
'one',
'two',
'three',
'four'
];
var schema = { mappings: { _default_: { properties: {} } } };
// inject all expected fields into schema mock
expectedFields.forEach(function (field) {
schema.mappings._default_.properties[field] = {};
});
var res = adminFields(schema, expectedFields);
t.deepEquals(res, expectedFields, 'all expected fields are returned');
t.end();
});
test('some expected fields in schema', function(t) {
var expectedFields = [
'one',
'two',
'three',
'four'
];
var schema = { mappings: { _default_: { properties: {} } } };
// inject only some of the expected fields into schema mock
expectedFields.slice(0, 3).forEach(function (field) {
schema.mappings._default_.properties[field] = {};
});
var res = adminFields(schema, expectedFields);
t.deepEquals(res, expectedFields.slice(0, 3), 'only matching expected fields are returned');
t.end();
});
test('no expected fields in schema', function(t) {
var schema = { mappings: { _default_: { properties: { foo: {} } } } };
var logErrorCalled = false;
var logger = {
error: function () {
logErrorCalled = true;
}};
var res = adminFields(schema, undefined, logger);
t.deepEquals(res, [], 'no admin fields found');
t.assert(logErrorCalled, 'log error called');
t.end();
});
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
return tape('adminFields: ' + name, testFunction);
}
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};

6
test/unit/helper/labelGenerator_GBR.js

@ -14,7 +14,7 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.one_main_street_uk = function(test, common) { module.exports.tests.one_main_street_uk = function(test, common) {
test('one main street uk', function(t) { test('one main street uk', function(t) {
var doc = { var doc = {
'name': { 'default': '1 Main St' }, 'name': '1 Main St',
'housenumber': '1', 'housenumber': '1',
'street': 'Main St', 'street': 'Main St',
'postalcode': 'BT77 0BG', 'postalcode': 'BT77 0BG',
@ -31,7 +31,7 @@ module.exports.tests.one_main_street_uk = function(test, common) {
module.exports.tests.hackney_city_farm = function(test, common) { module.exports.tests.hackney_city_farm = function(test, common) {
test('hackney city farm', function(t) { test('hackney city farm', function(t) {
var doc = { var doc = {
'name': { 'default': 'Hackney City Farm' }, 'name': 'Hackney City Farm',
'country_a': 'GBR', 'country_a': 'GBR',
'country': 'United Kingdom', 'country': 'United Kingdom',
'region': 'Hackney', 'region': 'Hackney',
@ -48,7 +48,7 @@ module.exports.tests.hackney_city_farm = function(test, common) {
module.exports.tests.wales = function(test, common) { module.exports.tests.wales = function(test, common) {
test('wales', function(t) { test('wales', function(t) {
var doc = { var doc = {
'name': { 'default': 'Wales' }, 'name': 'Wales',
'country_a': 'GBR', 'country_a': 'GBR',
'country': 'United Kingdom', 'country': 'United Kingdom',
'region': 'Wales' 'region': 'Wales'

4
test/unit/helper/labelGenerator_SGP.js

@ -14,7 +14,7 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.north_west_singapore = function(test, common) { module.exports.tests.north_west_singapore = function(test, common) {
test('north west singapore', function(t) { test('north west singapore', function(t) {
var doc = { var doc = {
'name': { 'default': 'North West' }, 'name': 'North West',
'country_a': 'SGP', 'country_a': 'SGP',
'country': 'Singapore', 'country': 'Singapore',
'region': 'North West' 'region': 'North West'
@ -28,7 +28,7 @@ module.exports.tests.north_west_singapore = function(test, common) {
module.exports.tests.singapore_mcdonalds = function(test, common) { module.exports.tests.singapore_mcdonalds = function(test, common) {
test('singapore_mcdonalds', function(t) { test('singapore_mcdonalds', function(t) {
var doc = { var doc = {
'name': { 'default': 'McDonald\'s' }, 'name': 'McDonald\'s',
'country_a': 'SGP', 'country_a': 'SGP',
'country': 'Singapore', 'country': 'Singapore',
'region': 'Central Singapore', 'region': 'Central Singapore',

4
test/unit/helper/labelGenerator_SWE.js

@ -14,7 +14,7 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.skane1 = function(test, common) { module.exports.tests.skane1 = function(test, common) {
test('skåne 1', function(t) { test('skåne 1', function(t) {
var doc = { var doc = {
'name': { 'default': 'Malmö' }, 'name': 'Malmö',
'country_a': 'SWE', 'country_a': 'SWE',
'country': 'Sweden', 'country': 'Sweden',
'region': 'Skåne', 'region': 'Skåne',
@ -29,7 +29,7 @@ module.exports.tests.skane1 = function(test, common) {
module.exports.tests.skane2 = function(test, common) { module.exports.tests.skane2 = function(test, common) {
test('skåne 2', function(t) { test('skåne 2', function(t) {
var doc = { var doc = {
'name': { 'default': 'Malmö' }, 'name': 'Malmö',
'country_a': 'SWE', 'country_a': 'SWE',
'country': 'Sweden', 'country': 'Sweden',
'region': 'Skåne', 'region': 'Skåne',

24
test/unit/helper/labelGenerator_USA.js

@ -12,7 +12,7 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.localadmin = function(test, common) { module.exports.tests.localadmin = function(test, common) {
test('localadmin should trump locality, neighbourhood, and county', function(t) { test('localadmin should trump locality, neighbourhood, and county', function(t) {
var doc = { var doc = {
'name': { 'default': 'Default Name' }, 'name': 'Default Name',
'country_a': 'USA', 'country_a': 'USA',
'country': 'United States', 'country': 'United States',
'region': 'Region Name', 'region': 'Region Name',
@ -30,7 +30,7 @@ module.exports.tests.localadmin = function(test, common) {
module.exports.tests.locality = function(test, common) { module.exports.tests.locality = function(test, common) {
test('locality should trump neighbourhood and county when localadmin not available', function(t) { test('locality should trump neighbourhood and county when localadmin not available', function(t) {
var doc = { var doc = {
'name': { 'default': 'Default Name' }, 'name': 'Default Name',
'country_a': 'USA', 'country_a': 'USA',
'country': 'United States', 'country': 'United States',
'region': 'Region Name', 'region': 'Region Name',
@ -47,7 +47,7 @@ module.exports.tests.locality = function(test, common) {
module.exports.tests.neighbourhood = function(test, common) { module.exports.tests.neighbourhood = function(test, common) {
test('neighbourhood should trump county when neither localadmin nor locality', function(t) { test('neighbourhood should trump county when neither localadmin nor locality', function(t) {
var doc = { var doc = {
'name': { 'default': 'Default Name' }, 'name': 'Default Name',
'country_a': 'USA', 'country_a': 'USA',
'country': 'United States', 'country': 'United States',
'region': 'Region Name', 'region': 'Region Name',
@ -63,7 +63,7 @@ module.exports.tests.neighbourhood = function(test, common) {
module.exports.tests.county = function(test, common) { module.exports.tests.county = function(test, common) {
test('county should be used when localadmin, locality, and neighbourhood are not available', function(t) { test('county should be used when localadmin, locality, and neighbourhood are not available', function(t) {
var doc = { var doc = {
'name': { 'default': 'Default Name' }, 'name': 'Default Name',
'country_a': 'USA', 'country_a': 'USA',
'country': 'United States', 'country': 'United States',
'region': 'Region Name', 'region': 'Region Name',
@ -78,7 +78,7 @@ module.exports.tests.county = function(test, common) {
module.exports.tests.region = function(test, common) { module.exports.tests.region = function(test, common) {
test('region should be used when region_a is not available', function(t) { test('region should be used when region_a is not available', function(t) {
var doc = { var doc = {
'name': { 'default': 'Default Name' }, 'name': 'Default Name',
'country_a': 'USA', 'country_a': 'USA',
'country': 'United States', 'country': 'United States',
'region': 'Region Name' 'region': 'Region Name'
@ -92,7 +92,7 @@ module.exports.tests.region = function(test, common) {
module.exports.tests.region_geonames = function(test, common) { module.exports.tests.region_geonames = function(test, common) {
test('default name should not be prepended when source=geonames and layer=region', function(t) { test('default name should not be prepended when source=geonames and layer=region', function(t) {
var doc = { var doc = {
'name': { 'default': 'Region Name' }, 'name': 'Region Name',
'country_a': 'USA', 'country_a': 'USA',
'country': 'United States', 'country': 'United States',
'region': 'Region Name', 'region': 'Region Name',
@ -109,7 +109,7 @@ module.exports.tests.region_geonames = function(test, common) {
module.exports.tests.region_whosonfirst = function(test, common) { module.exports.tests.region_whosonfirst = function(test, common) {
test('default name should not be prepended when source=whosonfirst and layer=region', function(t) { test('default name should not be prepended when source=whosonfirst and layer=region', function(t) {
var doc = { var doc = {
'name': { 'default': 'Region Name' }, 'name': 'Region Name',
'country_a': 'USA', 'country_a': 'USA',
'country': 'United States', 'country': 'United States',
'region': 'Region Name', 'region': 'Region Name',
@ -126,7 +126,7 @@ module.exports.tests.region_whosonfirst = function(test, common) {
module.exports.tests.region_other_source = function(test, common) { module.exports.tests.region_other_source = function(test, common) {
test('default name should be prepended when layer=region and source is not whosonfirst or geonames', function(t) { test('default name should be prepended when layer=region and source is not whosonfirst or geonames', function(t) {
var doc = { var doc = {
'name': { 'default': 'Default Name' }, 'name': 'Default Name',
'country_a': 'USA', 'country_a': 'USA',
'country': 'United States', 'country': 'United States',
'region': 'Region Name', 'region': 'Region Name',
@ -143,7 +143,7 @@ module.exports.tests.region_other_source = function(test, common) {
module.exports.tests.san_francisco = function(test, common) { module.exports.tests.san_francisco = function(test, common) {
test('san francisco', function(t) { test('san francisco', function(t) {
var doc = { var doc = {
'name': { 'default': 'San Francisco' }, 'name': 'San Francisco',
'country_a': 'USA', 'country_a': 'USA',
'country': 'United States', 'country': 'United States',
'region': 'California', 'region': 'California',
@ -160,7 +160,7 @@ module.exports.tests.san_francisco = function(test, common) {
module.exports.tests.nyc_office = function(test, common) { module.exports.tests.nyc_office = function(test, common) {
test('30 West 26th Street', function(t) { test('30 West 26th Street', function(t) {
var doc = { var doc = {
'name': { 'default': '30 West 26th Street' }, 'name': '30 West 26th Street',
'housenumber': '30', 'housenumber': '30',
'street': 'West 26th Street', 'street': 'West 26th Street',
'postalcode': '10010', 'postalcode': '10010',
@ -182,7 +182,7 @@ module.exports.tests.nyc_office = function(test, common) {
module.exports.tests.nyc_bakery = function(test, common) { module.exports.tests.nyc_bakery = function(test, common) {
test('New York Bakery', function(t) { test('New York Bakery', function(t) {
var doc = { var doc = {
'name': { 'default': 'New York Bakery' }, 'name': 'New York Bakery',
'housenumber': '51 W', 'housenumber': '51 W',
'street': '29th', 'street': '29th',
'country_a': 'USA', 'country_a': 'USA',
@ -203,7 +203,7 @@ module.exports.tests.nyc_bakery = function(test, common) {
module.exports.tests.ferry_building = function(test, common) { module.exports.tests.ferry_building = function(test, common) {
test('Ferry Building', function(t) { test('Ferry Building', function(t) {
var doc = { var doc = {
'name': { 'default': 'Ferry Building' }, 'name': 'Ferry Building',
'country_a': 'USA', 'country_a': 'USA',
'country': 'United States', 'country': 'United States',
'region': 'California', 'region': 'California',

32
test/unit/helper/labelGenerator_default.js

@ -14,7 +14,7 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.new_south_wales = function(test, common) { module.exports.tests.new_south_wales = function(test, common) {
test('new south wales', function(t) { test('new south wales', function(t) {
var doc = { var doc = {
'name': { 'default': 'New South Wales' }, 'name': 'New South Wales',
'country_a': 'AUS', 'country_a': 'AUS',
'country': 'Australia', 'country': 'Australia',
'region': 'New South Wales' 'region': 'New South Wales'
@ -28,7 +28,7 @@ module.exports.tests.new_south_wales = function(test, common) {
module.exports.tests.west_bengal = function(test, common) { module.exports.tests.west_bengal = function(test, common) {
test('west bengal', function(t) { test('west bengal', function(t) {
var doc = { var doc = {
'name': { 'default': 'West Bengal' }, 'name': 'West Bengal',
'country_a': 'IND', 'country_a': 'IND',
'country': 'India', 'country': 'India',
'region': 'West Bengal' 'region': 'West Bengal'
@ -42,7 +42,7 @@ module.exports.tests.west_bengal = function(test, common) {
module.exports.tests.bangalore = function(test, common) { module.exports.tests.bangalore = function(test, common) {
test('bangalore', function(t) { test('bangalore', function(t) {
var doc = { var doc = {
'name': { 'default': 'Bangalore' }, 'name': 'Bangalore',
'country_a': 'IND', 'country_a': 'IND',
'country': 'India', 'country': 'India',
'region': 'Karnataka', 'region': 'Karnataka',
@ -58,7 +58,7 @@ module.exports.tests.bangalore = function(test, common) {
module.exports.tests.sarjapur = function(test, common) { module.exports.tests.sarjapur = function(test, common) {
test('Sarjapur', function(t) { test('Sarjapur', function(t) {
var doc = { var doc = {
'name': { 'default': 'Sarjapur' }, 'name': 'Sarjapur',
'country_a': 'IND', 'country_a': 'IND',
'country': 'India', 'country': 'India',
'region': 'Karnataka' 'region': 'Karnataka'
@ -72,7 +72,7 @@ module.exports.tests.sarjapur = function(test, common) {
module.exports.tests.bengaluru_east = function(test, common) { module.exports.tests.bengaluru_east = function(test, common) {
test('Bengaluru East', function(t) { test('Bengaluru East', function(t) {
var doc = { var doc = {
'name': { 'default': 'Bengaluru East' }, 'name': 'Bengaluru East',
'country_a': 'IND', 'country_a': 'IND',
'country': 'India', 'country': 'India',
'region': 'Karnataka', 'region': 'Karnataka',
@ -90,7 +90,7 @@ module.exports.tests.bengaluru_east = function(test, common) {
module.exports.tests.wellington_victoria = function(test, common) { module.exports.tests.wellington_victoria = function(test, common) {
test('Wellington, Victoria, Australia', function(t) { test('Wellington, Victoria, Australia', function(t) {
var doc = { var doc = {
'name': { 'default': 'Wellington' }, 'name': 'Wellington',
'country_a': 'AUS', 'country_a': 'AUS',
'country': 'Australia', 'country': 'Australia',
'region': 'Victoria', 'region': 'Victoria',
@ -105,7 +105,7 @@ module.exports.tests.wellington_victoria = function(test, common) {
module.exports.tests.arbil = function(test, common) { module.exports.tests.arbil = function(test, common) {
test('arbil', function(t) { test('arbil', function(t) {
var doc = { var doc = {
'name': { 'default': 'Arbil' }, 'name': 'Arbil',
'country_a': 'IRQ', 'country_a': 'IRQ',
'country': 'Iraq', 'country': 'Iraq',
'region': 'Arbil' 'region': 'Arbil'
@ -119,7 +119,7 @@ module.exports.tests.arbil = function(test, common) {
module.exports.tests.madrid = function(test, common) { module.exports.tests.madrid = function(test, common) {
test('madrid', function(t) { test('madrid', function(t) {
var doc = { var doc = {
'name': { 'default': 'Madrid' }, 'name': 'Madrid',
'country_a': 'ESP', 'country_a': 'ESP',
'country': 'Spain', 'country': 'Spain',
'region': 'Madrid' 'region': 'Madrid'
@ -133,7 +133,7 @@ module.exports.tests.madrid = function(test, common) {
module.exports.tests.one_grolmanstrasse = function(test, common) { module.exports.tests.one_grolmanstrasse = function(test, common) {
test('one grolmanstrasse', function(t) { test('one grolmanstrasse', function(t) {
var doc = { var doc = {
'name': { 'default': '1 Grolmanstraße' }, 'name': '1 Grolmanstraße',
'housenumber': '1', 'housenumber': '1',
'street': 'Grolmanstraße', 'street': 'Grolmanstraße',
'postalcode': '10623', 'postalcode': '10623',
@ -153,7 +153,7 @@ module.exports.tests.one_grolmanstrasse = function(test, common) {
module.exports.tests.new_zealand = function(test, common) { module.exports.tests.new_zealand = function(test, common) {
test('new zealand', function(t) { test('new zealand', function(t) {
var doc = { var doc = {
'name': { 'default': 'New Zealand' }, 'name': 'New Zealand',
'country_a': 'NZL', 'country_a': 'NZL',
'country': 'New Zealand' 'country': 'New Zealand'
}; };
@ -166,7 +166,7 @@ module.exports.tests.new_zealand = function(test, common) {
module.exports.tests.republic_of_ireland = function(test, common) { module.exports.tests.republic_of_ireland = function(test, common) {
test('northern ireland', function(t) { test('northern ireland', function(t) {
var doc = { var doc = {
'name': { 'default': 'Ireland' }, 'name': 'Ireland',
'country_a': 'IRL', 'country_a': 'IRL',
'country': 'Ireland' 'country': 'Ireland'
}; };
@ -180,7 +180,7 @@ module.exports.tests.republic_of_ireland = function(test, common) {
module.exports.tests.krabi_province = function(test, common) { module.exports.tests.krabi_province = function(test, common) {
test('Krabi Provence', function(t) { test('Krabi Provence', function(t) {
var doc = { var doc = {
'name': { 'default': 'Krabi' }, 'name': 'Krabi',
'country_a': 'THA', 'country_a': 'THA',
'country': 'Thailand', 'country': 'Thailand',
'region': 'Krabi' 'region': 'Krabi'
@ -194,7 +194,7 @@ module.exports.tests.krabi_province = function(test, common) {
module.exports.tests.koh_lanta = function(test, common) { module.exports.tests.koh_lanta = function(test, common) {
test('Koh Lanta', function(t) { test('Koh Lanta', function(t) {
var doc = { var doc = {
'name': { 'default': 'Ko Lanta' }, 'name': 'Ko Lanta',
'country_a': 'THA', 'country_a': 'THA',
'country': 'Thailand', 'country': 'Thailand',
'region': 'Krabi' 'region': 'Krabi'
@ -208,7 +208,7 @@ module.exports.tests.koh_lanta = function(test, common) {
module.exports.tests.black_dog_cafe = function(test, common) { module.exports.tests.black_dog_cafe = function(test, common) {
test('Black Dog Cafe', function(t) { test('Black Dog Cafe', function(t) {
var doc = { var doc = {
'name': { 'default': 'Black Dog Cafe' }, 'name': 'Black Dog Cafe',
'country_a': 'NZL', 'country_a': 'NZL',
'country': 'New Zealand', 'country': 'New Zealand',
'region': 'Auckland Region', 'region': 'Auckland Region',
@ -223,7 +223,7 @@ module.exports.tests.black_dog_cafe = function(test, common) {
module.exports.tests.beach_bablyon = function(test, common) { module.exports.tests.beach_bablyon = function(test, common) {
test('Beach Bablyon', function(t) { test('Beach Bablyon', function(t) {
var doc = { var doc = {
'name': { 'default': 'Beach Bablyon' }, 'name': 'Beach Bablyon',
'country_a': 'NZL', 'country_a': 'NZL',
'country': 'New Zealand', 'country': 'New Zealand',
'region': 'Wellington Region', 'region': 'Wellington Region',
@ -240,7 +240,7 @@ module.exports.tests.beach_bablyon = function(test, common) {
module.exports.tests.waiotapu = function(test, common) { module.exports.tests.waiotapu = function(test, common) {
test('Waiotapu', function(t) { test('Waiotapu', function(t) {
var doc = { var doc = {
'name': { 'default': 'Waiotapu' }, 'name': 'Waiotapu',
'country_a': 'NZL', 'country_a': 'NZL',
'country': 'New Zealand', 'country': 'New Zealand',
'region': 'Bay of Plenty', 'region': 'Bay of Plenty',

3
test/unit/helper/type_mapping.js

@ -14,8 +14,7 @@ module.exports.tests.interfaces = function(test, common) {
t.deepEquals(type_mapping.layer_mapping.coarse, t.deepEquals(type_mapping.layer_mapping.coarse,
[ 'continent', 'macrocountry', 'country', 'dependency', [ 'continent', 'macrocountry', 'country', 'dependency',
'region', 'locality', 'localadmin', 'county', 'macrohood', 'region', 'locality', 'localadmin', 'county', 'macrohood',
'neighbourhood', 'microhood', 'disputed', 'admin0', 'neighbourhood', 'microhood', 'disputed' ]);
'admin1', 'admin2', 'neighborhood', 'locality', 'local_admin']);
t.end(); t.end();
}); });

14
test/unit/middleware/confidenceScore.js

@ -70,13 +70,21 @@ module.exports.tests.confidenceScore = function(test, common) {
value: 1, value: 1,
center_point: { lat: 100.1, lon: -50.5 }, center_point: { lat: 100.1, lon: -50.5 },
name: { default: 'test name1' }, name: { default: 'test name1' },
admin0: 'country1', admin1: 'state1', admin2: 'city1' parent: {
country: 'country1',
region: 'state1',
county: 'city1'
}
}, { }, {
_score: 20,
value: 2, value: 2,
center_point: { lat: 100.2, lon: -51.5 }, center_point: { lat: 100.2, lon: -51.5 },
name: { default: 'test name2' }, name: { default: 'test name2' },
admin0: 'country2', admin1: 'state2', admin2: 'city2', parent: {
_score: 20 country: 'country2',
region: 'state2',
county: 'city2'
}
}], }],
meta: {scores: [10]} meta: {scores: [10]}
}; };

22
test/unit/middleware/localNamingConventions.js

@ -15,9 +15,11 @@ module.exports.tests.flipNumberAndStreet = function(test, common) {
'number': '1', 'number': '1',
'street': 'Main St' 'street': 'Main St'
}, },
'admin1': 'Dungannon', 'parent': {
'alpha3': 'GBR', 'region': 'Dungannon',
'admin0': 'United Kingdom' 'country_a': 'GBR',
'country': 'United Kingdom'
}
}; };
var deAddress = { var deAddress = {
@ -30,12 +32,14 @@ module.exports.tests.flipNumberAndStreet = function(test, common) {
'number': '23', 'number': '23',
'street': 'Grolmanstraße' 'street': 'Grolmanstraße'
}, },
'admin1': 'Berlin', 'parent': {
'locality': 'Berlin', 'region': 'Berlin',
'alpha3': 'DEU', 'locality': 'Berlin',
'admin2': 'Berlin', 'country_a': 'DEU',
'admin0': 'Germany', 'county': 'Berlin',
'neighborhood': 'Hansaviertel' 'country': 'Germany',
'neighbourhood': 'Hansaviertel'
}
}; };
var req = {}, var req = {},

8
test/unit/mock/backend.js

@ -15,7 +15,7 @@ responses['client/search/ok/1'] = function( cmd, cb ){
value: 1, value: 1,
center_point: { lat: 100.1, lon: -50.5 }, center_point: { lat: 100.1, lon: -50.5 },
name: { default: 'test name1' }, name: { default: 'test name1' },
admin0: 'country1', admin1: 'state1', admin2: 'city1' parent: { country: 'country1', region: 'state1', county: 'city1' }
} }
}, { }, {
_id: 'myid2', _id: 'myid2',
@ -25,7 +25,7 @@ responses['client/search/ok/1'] = function( cmd, cb ){
value: 2, value: 2,
center_point: { lat: 100.2, lon: -51.5 }, center_point: { lat: 100.2, lon: -51.5 },
name: { default: 'test name2' }, name: { default: 'test name2' },
admin0: 'country2', admin1: 'state2', admin2: 'city2' parent: { country: 'country2', region: 'state2', county: 'city2' }
} }
}])); }]));
}; };
@ -43,7 +43,7 @@ responses['client/mget/ok/1'] = function( cmd, cb ){
value: 1, value: 1,
center_point: { lat: 100.1, lon: -50.5 }, center_point: { lat: 100.1, lon: -50.5 },
name: { default: 'test name1' }, name: { default: 'test name1' },
admin0: 'country1', admin1: 'state1', admin2: 'city1' parent: { country: 'country1', region: 'state1', county: 'city1' }
} }
}, { }, {
_id: 'myid2', _id: 'myid2',
@ -54,7 +54,7 @@ responses['client/mget/ok/1'] = function( cmd, cb ){
value: 2, value: 2,
center_point: { lat: 100.2, lon: -51.5 }, center_point: { lat: 100.2, lon: -51.5 },
name: { default: 'test name2' }, name: { default: 'test name2' },
admin0: 'country2', admin1: 'state2', admin2: 'city2' parent: { country: 'country2', region: 'state2', county: 'city2' }
} }
}])); }]));
}; };

9
test/unit/query/search.js

@ -126,8 +126,7 @@ module.exports.tests.query = function(test, common) {
test('valid query with a full valid address', function(t) { test('valid query with a full valid address', function(t) {
var address = '123 main st new york ny 10010 US'; var address = '123 main st new york ny 10010 US';
var query = generate({ text: address, var query = generate({ text: address,
layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', layers: [ 'address', 'venue', 'country', 'region', 'county', 'neighbourhood', 'locality', 'localadmin' ],
'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
querySize: 10, querySize: 10,
parsed_text: parser.get_parsed_address(address), parsed_text: parser.get_parsed_address(address),
}); });
@ -142,8 +141,7 @@ module.exports.tests.query = function(test, common) {
test('valid query with partial address', function(t) { test('valid query with partial address', function(t) {
var partial_address = 'soho grand, new york'; var partial_address = 'soho grand, new york';
var query = generate({ text: partial_address, var query = generate({ text: partial_address,
layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', layers: [ 'address', 'venue', 'country', 'region', 'county', 'neighbourhood', 'locality', 'localadmin' ],
'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
querySize: 10, querySize: 10,
parsed_text: parser.get_parsed_address(partial_address), parsed_text: parser.get_parsed_address(partial_address),
}); });
@ -158,8 +156,7 @@ module.exports.tests.query = function(test, common) {
test('valid query with regions in address', function(t) { test('valid query with regions in address', function(t) {
var partial_address = '1 water st manhattan ny'; var partial_address = '1 water st manhattan ny';
var query = generate({ text: partial_address, var query = generate({ text: partial_address,
layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', layers: [ 'address', 'venue', 'country', 'region', 'county', 'neighbourhood', 'locality', 'localadmin' ],
'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
querySize: 10, querySize: 10,
parsed_text: parser.get_parsed_address(partial_address), parsed_text: parser.get_parsed_address(partial_address),
}); });

12
test/unit/sanitiser/_layers.js

@ -43,7 +43,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
var admin_layers = [ 'continent', 'macrocountry', 'country', 'dependency', var admin_layers = [ 'continent', 'macrocountry', 'country', 'dependency',
'region', 'locality', 'localadmin', 'county', 'macrohood', 'neighbourhood', 'region', 'locality', 'localadmin', 'county', 'macrohood', 'neighbourhood',
'microhood', 'disputed', 'admin0', 'admin1', 'admin2', 'neighborhood', 'local_admin' ]; 'microhood', 'disputed' ];
t.deepEqual(clean.layers, admin_layers, 'coarse layers set'); t.deepEqual(clean.layers, admin_layers, 'coarse layers set');
t.end(); t.end();
@ -65,7 +65,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
sanitize(raw, clean); sanitize(raw, clean);
var expected_layers = ['venue', 'country', 'admin0', 'region', 'admin1']; var expected_layers = ['venue', 'country', 'region'];
t.deepEqual(clean.layers, expected_layers, 'venue + regular layers'); t.deepEqual(clean.layers, expected_layers, 'venue + regular layers');
t.end(); t.end();
}); });
@ -78,7 +78,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
var expected_layers = [ 'continent', 'macrocountry', 'country', 'dependency', var expected_layers = [ 'continent', 'macrocountry', 'country', 'dependency',
'region', 'locality', 'localadmin', 'county', 'macrohood', 'neighbourhood', 'region', 'locality', 'localadmin', 'county', 'macrohood', 'neighbourhood',
'microhood', 'disputed', 'admin0', 'admin1', 'admin2', 'neighborhood', 'local_admin' ]; 'microhood', 'disputed' ];
t.deepEqual(clean.layers, expected_layers, 'coarse + regular layers set'); t.deepEqual(clean.layers, expected_layers, 'coarse + regular layers set');
t.end(); t.end();
@ -90,7 +90,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
sanitize(raw, clean); sanitize(raw, clean);
var expected_layers = ['address', 'country', 'admin0', 'locality' ]; var expected_layers = ['address', 'country', 'locality' ];
t.deepEqual(clean.layers, expected_layers, 'address + regular layers set'); t.deepEqual(clean.layers, expected_layers, 'address + regular layers set');
t.end(); t.end();
}); });
@ -101,7 +101,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
sanitize(raw, clean); sanitize(raw, clean);
var expected_layers = ['venue', 'country', 'admin0']; var expected_layers = ['venue', 'country'];
t.deepEqual(clean.layers, expected_layers, 'venue layers found (no duplicates)'); t.deepEqual(clean.layers, expected_layers, 'venue layers found (no duplicates)');
t.end(); t.end();
}); });
@ -115,7 +115,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
var coarse_layers = [ 'continent', 'macrocountry', var coarse_layers = [ 'continent', 'macrocountry',
'country', 'dependency', 'region', 'locality', 'localadmin', 'country', 'dependency', 'region', 'locality', 'localadmin',
'county', 'macrohood', 'neighbourhood', 'microhood', 'county', 'macrohood', 'neighbourhood', 'microhood',
'disputed', 'admin0', 'admin1', 'admin2', 'neighborhood', 'local_admin']; 'disputed' ];
var venue_layers = [ 'venue' ]; var venue_layers = [ 'venue' ];
var expected_layers = venue_layers.concat(coarse_layers); var expected_layers = venue_layers.concat(coarse_layers);

4
test/unit/sanitiser/_sources.js

@ -29,7 +29,7 @@ module.exports.tests.no_sources = function(test, common) {
}; };
var expected_error = 'sources parameter cannot be an empty string. ' + var expected_error = 'sources parameter cannot be an empty string. ' +
'Valid options: osm,oa,gn,qs,wof,openstreetmap,openaddresses,geonames,quattroshapes,whosonfirst'; 'Valid options: osm,oa,gn,wof,openstreetmap,openaddresses,geonames,whosonfirst';
var messages = sanitize(req.query, req.clean); var messages = sanitize(req.query, req.clean);
@ -104,7 +104,7 @@ module.exports.tests.invalid_sources = function(test, common) {
var expected_messages = { var expected_messages = {
errors: [ errors: [
'\'notasource\' is an invalid sources parameter. ' + '\'notasource\' is an invalid sources parameter. ' +
'Valid options: osm,oa,gn,qs,wof,openstreetmap,openaddresses,geonames,quattroshapes,whosonfirst' 'Valid options: osm,oa,gn,wof,openstreetmap,openaddresses,geonames,whosonfirst'
], ],
warnings: [] warnings: []
}; };

2
test/unit/sanitiser/search.js

@ -72,7 +72,7 @@ module.exports.tests.sanitise_valid_text = function(test, common) {
}; };
module.exports.tests.sanitize_text_with_delim = function(test, common) { module.exports.tests.sanitize_text_with_delim = function(test, common) {
var texts = [ 'a,bcd', '123 main st, admin1', ',,,', ' ' ]; var texts = [ 'a,bcd', '123 main st, region', ',,,', ' ' ];
test('valid texts with a comma', function(t) { test('valid texts with a comma', function(t) {
texts.forEach( function( text ){ texts.forEach( function( text ){

4
test/unit/service/mget.js

@ -20,14 +20,14 @@ module.exports.tests.functional_success = function(test, common) {
value: 1, value: 1,
center_point: { lat: 100.1, lon: -50.5 }, center_point: { lat: 100.1, lon: -50.5 },
name: { default: 'test name1' }, name: { default: 'test name1' },
admin0: 'country1', admin1: 'state1', admin2: 'city1' parent: { country: 'country1', region: 'state1', county: 'city1' }
}, },
{ {
_id: 'myid2', _type: 'mytype2', _id: 'myid2', _type: 'mytype2',
value: 2, value: 2,
center_point: { lat: 100.2, lon: -51.5 }, center_point: { lat: 100.2, lon: -51.5 },
name: { default: 'test name2' }, name: { default: 'test name2' },
admin0: 'country2', admin1: 'state2', admin2: 'city2' parent: { country: 'country2', region: 'state2', county: 'city2' }
} }
]; ];

4
test/unit/service/search.js

@ -23,7 +23,7 @@ module.exports.tests.functional_success = function(test, common) {
value: 1, value: 1,
center_point: { lat: 100.1, lon: -50.5 }, center_point: { lat: 100.1, lon: -50.5 },
name: { default: 'test name1' }, name: { default: 'test name1' },
admin0: 'country1', admin1: 'state1', admin2: 'city1' parent: { country: 'country1', region: 'state1', county: 'city1' }
}, },
{ {
_id: 'myid2', _type: 'mytype2', _id: 'myid2', _type: 'mytype2',
@ -31,7 +31,7 @@ module.exports.tests.functional_success = function(test, common) {
value: 2, value: 2,
center_point: { lat: 100.2, lon: -51.5 }, center_point: { lat: 100.2, lon: -51.5 },
name: { default: 'test name2' }, name: { default: 'test name2' },
admin0: 'country2', admin1: 'state2', admin2: 'city2' parent: { country: 'country2', region: 'state2', county: 'city2' }
} }
]; ];

Loading…
Cancel
Save