Skip to content

Commit

Permalink
Corrrectly filter /place queries by layer
Browse files Browse the repository at this point in the history
`/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

Fixes pelias/pelias#643
  • Loading branch information
orangejulius committed Oct 18, 2017
1 parent 4df3922 commit be17250
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion controller/place.js
Expand Up @@ -38,7 +38,7 @@ function setup( apiConfig, esclient ){
const cmd = req.clean.ids.map( function(id) {
return {
_index: apiConfig.indexName,
_type: id.layers,
_type: id.layer,
_id: id.id
};
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/controller/place.js
Expand Up @@ -51,11 +51,11 @@ module.exports.tests.success = (test, common) => {
ids: [
{
id: 'id1',
layers: 'layer1'
layer: 'layer1'
},
{
id: 'id2',
layers: 'layer2'
layer: 'layer2'
}
]
},
Expand Down

0 comments on commit be17250

Please sign in to comment.