diff --git a/mappings/document.js b/mappings/document.js index 88d94426..9e7f5cf2 100644 --- a/mappings/document.js +++ b/mappings/document.js @@ -1,4 +1,5 @@ var admin = require('./partial/admin'); +var postalcode = require('./partial/postalcode'); var hash = require('./partial/hash'); var multiplier = require('./partial/multiplier'); var literal = require('./partial/literal'); @@ -95,7 +96,12 @@ var schema = { // https://github.com/whosonfirst/whosonfirst-placetypes#neighbourhood neighbourhood: admin, neighbourhood_a: admin, - neighbourhood_id: literal + neighbourhood_id: literal, + + // https://github.com/whosonfirst/whosonfirst-placetypes#postalcode + postalcode: postalcode, + postalcode_a: postalcode, + postalcode_id: literal } }, diff --git a/mappings/partial/postalcode.json b/mappings/partial/postalcode.json new file mode 100644 index 00000000..f04099e6 --- /dev/null +++ b/mappings/partial/postalcode.json @@ -0,0 +1,5 @@ +{ + "type": "string", + "analyzer": "peliasZip", + "store": "yes" +} \ No newline at end of file diff --git a/test/document.js b/test/document.js index 3cfc1efe..c57b818f 100644 --- a/test/document.js +++ b/test/document.js @@ -20,7 +20,9 @@ module.exports.tests.properties = function(test, common) { // should contain the correct field definitions module.exports.tests.fields = function(test, common) { - var fields = ['source', 'layer', 'alpha3', 'name', 'phrase', 'address_parts', 'parent', 'center_point', 'shape', 'bounding_box', 'source_id', 'category', 'population', 'popularity']; + var fields = ['source', 'layer', 'alpha3', 'name', 'phrase', 'address_parts', + 'parent', 'center_point', 'shape', 'bounding_box', 'source_id', 'category', + 'population', 'popularity']; test('fields specified', function(t) { t.deepEqual(Object.keys(schema.properties), fields); t.end(); @@ -75,7 +77,19 @@ module.exports.tests.address_analysis = function(test, common) { // should contain the correct parent field definitions module.exports.tests.parent_fields = function(test, common) { - var fields = ['country', 'country_a', 'country_id', 'dependency', 'dependency_a', 'dependency_id', 'macroregion', 'macroregion_a', 'macroregion_id', 'region', 'region_a', 'region_id', 'macrocounty', 'macrocounty_a', 'macrocounty_id', 'county', 'county_a', 'county_id', 'locality', 'locality_a', 'locality_id', 'borough', 'borough_a', 'borough_id', 'localadmin', 'localadmin_a', 'localadmin_id', 'neighbourhood', 'neighbourhood_a', 'neighbourhood_id']; + var fields = [ + 'country', 'country_a', 'country_id', + 'dependency', 'dependency_a', 'dependency_id', + 'macroregion', 'macroregion_a', 'macroregion_id', + 'region', 'region_a', 'region_id', + 'macrocounty', 'macrocounty_a', 'macrocounty_id', + 'county', 'county_a', 'county_id', + 'locality', 'locality_a', 'locality_id', + 'borough', 'borough_a', 'borough_id', + 'localadmin', 'localadmin_a', 'localadmin_id', + 'neighbourhood', 'neighbourhood_a', 'neighbourhood_id', + 'postalcode', 'postalcode_a', 'postalcode_id' + ]; test('parent fields specified', function(t) { t.deepEqual(Object.keys(schema.properties.parent.properties), fields); t.end(); @@ -99,6 +113,17 @@ module.exports.tests.parent_analysis = function(test, common) { t.end(); }); }); + + test('postalcode', function(t) { + t.equal(prop['postalcode'].type, 'string'); + t.equal(prop['postalcode'].analyzer, 'peliasZip'); + t.equal(prop['postalcode'+'_a'].type, 'string'); + t.equal(prop['postalcode'+'_a'].analyzer, 'peliasZip'); + t.equal(prop['postalcode'+'_id'].type, 'string'); + t.equal(prop['postalcode'+'_id'].analyzer, 'keyword'); + + t.end(); + }); }; module.exports.tests.alpha3_analysis = function(test, common) { diff --git a/test/fixtures/expected.json b/test/fixtures/expected.json index 4f31a6aa..ebc61088 100644 --- a/test/fixtures/expected.json +++ b/test/fixtures/expected.json @@ -1771,6 +1771,21 @@ "type": "string", "analyzer": "keyword", "store": "yes" + }, + "postalcode": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_a": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_id": { + "type": "string", + "analyzer": "keyword", + "store": "yes" } } }, @@ -2049,6 +2064,21 @@ "type": "string", "analyzer": "keyword", "store": "yes" + }, + "postalcode": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_a": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_id": { + "type": "string", + "analyzer": "keyword", + "store": "yes" } } }, @@ -2327,6 +2357,21 @@ "type": "string", "analyzer": "keyword", "store": "yes" + }, + "postalcode": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_a": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_id": { + "type": "string", + "analyzer": "keyword", + "store": "yes" } } }, @@ -2605,6 +2650,21 @@ "type": "string", "analyzer": "keyword", "store": "yes" + }, + "postalcode": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_a": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_id": { + "type": "string", + "analyzer": "keyword", + "store": "yes" } } }, @@ -2883,6 +2943,21 @@ "type": "string", "analyzer": "keyword", "store": "yes" + }, + "postalcode": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_a": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_id": { + "type": "string", + "analyzer": "keyword", + "store": "yes" } } }, @@ -3161,6 +3236,21 @@ "type": "string", "analyzer": "keyword", "store": "yes" + }, + "postalcode": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_a": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_id": { + "type": "string", + "analyzer": "keyword", + "store": "yes" } } }, @@ -3439,6 +3529,21 @@ "type": "string", "analyzer": "keyword", "store": "yes" + }, + "postalcode": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_a": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_id": { + "type": "string", + "analyzer": "keyword", + "store": "yes" } } }, @@ -3717,6 +3822,21 @@ "type": "string", "analyzer": "keyword", "store": "yes" + }, + "postalcode": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_a": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_id": { + "type": "string", + "analyzer": "keyword", + "store": "yes" } } }, @@ -3995,6 +4115,21 @@ "type": "string", "analyzer": "keyword", "store": "yes" + }, + "postalcode": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_a": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_id": { + "type": "string", + "analyzer": "keyword", + "store": "yes" } } }, @@ -4273,6 +4408,21 @@ "type": "string", "analyzer": "keyword", "store": "yes" + }, + "postalcode": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_a": { + "type": "string", + "analyzer": "peliasZip", + "store": "yes" + }, + "postalcode_id": { + "type": "string", + "analyzer": "keyword", + "store": "yes" } } },