feat(autocomplete): filter out address records for character counts below threshold - #1219
Conversation
69586e2 to
d945b97
Compare
|
@orangejulius I'm happy with this as-is, ready to merge unless you have any concerns? |
|
oh, fascinating regarding the performance of |
|
here are a few of the top hits I found on Google for "elasticsearch must_not slow" |
|
In particular this comment: https://discuss.elastic.co/t/must-not-in-bool-filter-much-slower-than-must-for-same-terms-filter/1479/13
|
|
I had a chance to test this out against a full planet build yesterday. It looks super promising, the highest number of Elasticsearch hits I saw was 10 million, down from ~130M without. I'm working on some code to let us configure the threshold before which address results are filtered out. Once that looks good, we can and should merge this! |
d945b97 to
f20523f
Compare
|
I just pushed a change to this branch that drives text length value from config rather than hardcoding it to two. It defaults to zero, making this PR a no-op by default. Some new helper methods from pelias/config#104 were required to test this, so the |
f20523f to
cacbb16
Compare
cacbb16 to
3c37e94
Compare


READY TO MERGE
This PR will allow us to provide a negative layer filter so that autocomplete will not search on theaddresslayer for one or two character inputs.After testing this I discovered that
must_notconditions do not create a bitmask asfilterconditions do, so what ends up happening is that the same amount of hits are returned and then an iterator is generated to run over the results of themustand enforce themust_not.tl;dr
must_notis super slow for large hit counts and lots of people on the internet are complaining about how it's not very well implemented.So I've rewritten the query to use a positive filter, we compute the difference between
all layersand theexcluded layers. Fortunately this is now super easy to do since the work I did a couple months back to clean up thetype_mappingmodule :)Well covered with unit tests and fixtures, I played with it a bit on North America and couldn't see any real difference in perceived quality for one-or-two char inputs.
The effect of this will be a huge improvement in performance for one and two character queries, the address layer accounts for ~90% of matches.