Skip to content

Commit f928119

Browse files
committed
Corrrectly filter /place queries by layer
`/place` queries have been executing in a way where only the ID, but not the layer, has been considered when returning records from Elasticsearch. It turns out this bug was introduced almost a year and a half ago in #407. A little, relatively unimportant bit of code was looking for a property called `layers`: ``` const cmd = req.clean.ids.map( function(id) { return { _index: apiConfig.indexName, _type: id.layers, _id: id.id }; }); ``` The correct property was `layer`, so no filtering on layer was done in the resulting [mget](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html) query. There was never an acceptance test for these sorts of queries, but there is now one in pelias/acceptance-tests#446. The unit tests were enforcing the incorrect behavior. Fixes pelias/pelias#643
1 parent 99b98a7 commit f928119

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

controller/place.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function setup( apiConfig, esclient ){
3838
const cmd = req.clean.ids.map( function(id) {
3939
return {
4040
_index: apiConfig.indexName,
41-
_type: id.layers,
41+
_type: id.layer,
4242
_id: id.id
4343
};
4444
});

test/unit/controller/place.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ module.exports.tests.success = (test, common) => {
5151
ids: [
5252
{
5353
id: 'id1',
54-
layers: 'layer1'
54+
layer: 'layer1'
5555
},
5656
{
5757
id: 'id2',
58-
layers: 'layer2'
58+
layer: 'layer2'
5959
}
6060
]
6161
},

0 commit comments

Comments
 (0)