Skip to content

Commit

Permalink
Merge pull request #210 from pelias/add-postalcode
Browse files Browse the repository at this point in the history
Add postalcode to parent hierarchy
  • Loading branch information
Diana Shkolnikov authored Feb 9, 2017
2 parents 1aa457c + 063536b commit f55dc3a
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 3 deletions.
8 changes: 7 additions & 1 deletion mappings/document.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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
}
},

Expand Down
5 changes: 5 additions & 0 deletions mappings/partial/postalcode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "string",
"analyzer": "peliasZip",
"store": "yes"
}
29 changes: 27 additions & 2 deletions test/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down
150 changes: 150 additions & 0 deletions test/fixtures/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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"
}
}
},
Expand Down

0 comments on commit f55dc3a

Please sign in to comment.