Repository navigation
feat: Add excluding for categories - #143
arnesetzer wants to merge 2 commits into
Conversation
Joxit
left a comment
There was a problem hiding this comment.
Hi,
Thank you for using pelias and submitting PR 😄
I put some comments in your code.
Could you also keep the same indentation / code style on all unchanged lines ? This will help us for the review and reduce the number of unnecessary changes.
bcb0954 to
c52f0a3
Compare
c52f0a3 to
e17334a
Compare
|
Fixed the mix up. Sorry again. After running |
| } | ||
|
|
||
| // base view | ||
| var view = { terms: {} }; |
There was a problem hiding this comment.
You could have keep the view with something like
const view = { bool: { } };And then view.bool.must = [ terms(...) ] or view.bool.must_not = [ terms(...) ]
Thanks to this you will have only two conditions and one return
| @@ -1,21 +1,40 @@ | |||
| const terms = require('../lib/leaf/terms'); | |||
|
|
|||
| function asArray( value ){ | |||
There was a problem hiding this comment.
lodash _.concat(value) is doing the same, but IDK which one is better
| const must_not = []; | ||
|
|
||
| if( vs.isset('input:categories') ){ | ||
| must.push( terms( field, asArray( vs.var('input:categories').get() ) ) ); |
There was a problem hiding this comment.
You can split this in two lines, first one being const value = asArray(...) if you think this is too long
|
Hey @arnesetzer thanks for the PR. Two concerns here. First, I just want to make sure I understand the use case here. I'm guessing you want to be able to form queries like "every type of venue except transit" or "every amenity subcategory except Second, adding new parameters is a tough one because they either have to be provably okay for performance in all cases (like negative layers was), or behind a Using There are generally lots more possible category values than layers values, so the same approach could work, but it's a bit unweildy if the elasticsearch queries we are generating might have a I'm sure you're groaning at the idea of adding a config flag to enable/disable this parameter, so I'm now kinda wondering if we should build a system where any parameter that isn't required can be disabled in |
More or less, we import the categories as venues via the CSV importer and use the categories (and addendum_json) to filter them (different icons in the search results, etc.). For a specific search, we want to exclude certain categories. I thought it would be the same with layers ('-xyz' excludes 'xyz'), but this was not the case. As we needed this kind of filtering anyway and did not want to filter on the client side, I implemented this solution.
I was not aware of this. When using only custom POIs (approximately 10⁶) on a relatively small index (<10⁹ entries in Elasticsearch), I did not recognise any performance issues. However, you are right that using the OSM categories for the whole world will significantly increase the size and probably slow down the geocoder.
Just to clarify, are we talking about parameters such as 'layer', 'category' and 'alt_name' (which, if I recall correctly, is not currently indexed at all), or specific categories? If it's the latter, my case would still be valid, since I need to enable and disable specific categories dynamically. |
👋 I did some awesome work for the Pelias project and would love for everyone to have a look at it and provide feedback.
This is the first of two PRs who needs to be merged together. The second one is here: pelias/api#1725
Here's the reason for this change 🚀
For a project I need the functionality to exclude categories like layers which is currently not possible. Maybe it is a useful thing to have on upstream.
Here's what actually got changed 👏
Here's how others can test the changes 👀