api icon indicating copy to clipboard operation
api copied to clipboard

search: interpolation results included for layers=-address

Open missinglink opened this issue 1 year ago • 0 comments

When interpolations are generated, they are always of type address, however it's possible for the API to return these results even when the layers are specified in a way that excludes the address layer.

For example: https://pelias.github.io/compare/#/v1/search?layers=street&text=10+Brunswick+Street%2C+VIC

In this case the query specifically requested layers=street yet the result set contains rows from the address layer.

Screenshot 2024-03-28 at 11 52 04

The cause of this issue is in the interpolationShouldExecute predicate, which should take into account the requested layers and not execute if the address layer is not targeted:

https://github.com/pelias/api/blob/e6f532b18577c8436a10651c07e5a2e9f5fdb1ea/routes/v1.js#L182-L187

Note: this should also improve performance for these queries.

missinglink avatar Mar 28 '24 10:03 missinglink