Default to 'and' operator for match queries. Remove slug search, prioritize exact matches more.#7303
Conversation
…ritize exact matches more. References many "component: search" issues. What I tested with a database of all public add-ons: Example searches: tab center redux - should find "Tab Center Redux" while "Tab Mix Plus" is probably second and "Redux DevTools" 4th or so Open Image in New Tab -> should find "Open Image in New Tab" while "Open Bookmarks in New Tab" should be 2nd or 3rd CoinHive -> Finds "Coinhive Blocker", "CoinBlock" (prefix search) and "NoMiners" (description) Privacy -> Finds "Privacy Badger", "Privacy Pass", "Privacy Settings", "Google Privacy" (probably 4th or so) and "Blur" (summary + description + many users). Scores "Ghostery" on the first page but ranks it in the middle firebu -> Finds "Firebug", "Firebug Autocompleter", "Firefinder for Firebug" fireb -> Scores "Fire Drag" first, puts "Firebug" approximately 3rd or so Menu Wizzard -> Finds "Menu Wizard" (fuzzy, typo) first, then "Add-ons Manager Context Menu" apparently because it matches good in the title and has many users Frame Demolition -> Finds "Frame Demolition" Demolition -> Finds only "Frame Demolition", same for "Demolation" (typo) reStyle -> Finds "reStyle" and scores a few add-ons that match on "restore" next since the term is similar MegaUpload DownloadHelper -> finds "MegaUpload DownloadHelper" first, scores "Video DownloadHelper" and "RadpidShare DownloadHelper" next. Doesn't find "Popup Blocker" anymore as currently happening on -prod MegaUpload -> only finds "MegaUpload DownloadHelper" and nothing else No Flash -> Scores "No Flash" first, then depending on users "Download Flash and Video", "YouTube Flash Video Player" and "YouTube Flash Player" (not necessarily in that order) Disable Hello, Pocket & Reader+ -> finds "Disable Hello, Pocket & Reader+" first (yeay!), then scores "Reader", "Disable WebRTC" and "In My Pocket" next similarly to what's happening on -prod currently Not working yet: privacybadger -> "Privacy Badger" -> will probably need some kind of ngram filtering and analyzing (#591) eyes -> 'decentraleyes' -> Not sure this should actually work, will probably need some more analyzing too (#591) Not sure if it's specifically only because of these changes but #3248 is fixed. This potentially fixes #7244, #6891, #6837, #6417, mozilla/addons#359. Not sure if this fixes #mozilla/addons#567 but the results look much more promising and the amount of results doesn't explode here. I only have 2.8k add-ons for testing though so I'm not too sure. And might be relevant to #6137. This is a big step towards #2661, I doubt we can call this fixed though.
|
Note: I'm working on figuring out that legacy api test failure, looks kinda weird since the actual problem is that for some reason |
|
What's the argument in favour of merging this without unittests? It's not a large changeset currently - is one of the issues a particularly urgent fix? |
|
I'm with @eviljeff : I don't think it's particularly urgent, so we should wait for tests (well they are broken currently so we have to wait anyway). Just a simple search view test proving that all the words are now used vs only a few should be enough. PS: why removing the slug? The rest of the changes seem to make sense at first glance. |
|
Alrighty, I'll spare some more time then and work on proper tests. I'll try to update the PR tomorrow (Wed) and see how that goes. |
There were more than a handful scenarios where removing the slug immensely improved the overall scoring. As we already discussed some time ago I still believe that searching on the slug might not be the best idea since it's more or less one word for ElasticSearch right now with some fancy punctuation in there. Sometimes it's even truncated. It sure messes up fuzzy searches on which we rely quite a bit. I can try to write some more tests to prove that though, this is mainly from the search-scenarios above and a few other tests. |
That explanation is enough for me. Maybe add a comment somewhere so that we're not tempted to add it back? |
|
I'll do that
On Tue, Jan 16, 2018, at 10:55 PM, Mathieu Pillard wrote:
> There were more than a handful scenarios where removing the slug
> immensely improved the overall scoring. As we already discussed
> some time ago I still believe that searching on the slug might not
> be the best idea since it's more or less one word for
> ElasticSearch right now with some fancy punctuation in there.
> Sometimes it's even truncated. It sure messes up fuzzy searches on
> which we rely quite a bit.>> I can try to write some more tests to prove that though, this is
> mainly from the search-scenarios above and a few other tests.> That explanation is enough for me. Maybe add a comment somewhere so
that we're not tempted to add it back?> — You are receiving this because you authored the thread. Reply to
this email directly, view it on GitHub[1], or mute the thread[2].>
|
…y one shard and one replica
|
Alrighty, I added tests and re-configured our test settings to only have one replica and one shard to make the scoring more reliable. Alternatively we might want to think about using https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-search-type.html#dfs-query-then-fetch which doesn't sound too bad imho, might hurt performance though. |
… allow us to test this later too via a waffle flag.
…sts to be able to handle the waffle-flag
…operly. More serializer fixes
|
FYI: There are a few TODOs in some tests still, I'd like to get them work more incrementally and focus on the big picture first maybe, some are obscure but should work eventually. I'll also squash this before merging, I usually don't like squashing while in a pull request |
| view.request = self.request | ||
| qset = view.get_queryset() | ||
|
|
||
| return qset.filter('term', id=self.addon.pk).execute()[0] |
There was a problem hiding this comment.
nit : we use qs pretty much everywhere. Applies to a lot of other parts below.
| self.request, | ||
| 'search-use-dfs-query-then-fetch') | ||
| if dfs_query_then_fetch: | ||
| qset = qset.params(search_type='dfs_query_then_fetch') |
There was a problem hiding this comment.
I understand why you're doing this after reading ES doc, but it deserves a comment.
| name='Amazon 1-Click Lock', type=amo.ADDON_EXTENSION, | ||
| average_daily_users=50, weekly_downloads=0), | ||
|
|
||
| cls.refresh() |
There was a problem hiding this comment.
An improvement for later: prevent the individual index calls while you're adding all these add-ons, then call reindex instead of refresh.
There was a problem hiding this comment.
Good idea, I'll add it to my list of future improvements and will open an issue about it
|
|
||
| def test_scenario_megaupload(self): | ||
| self._check_scenario('MegaUpload', ( | ||
| # I have litterally NO idea :-/ |
|
|
||
| def test_scenario_no_flash(self): | ||
| # TODO: Doesn't put "No Flash" on first line, does the "No" | ||
| # do something special here? |
There was a problem hiding this comment.
That's true but the "no idea" part comes where we have a raw term match and IMHO (correct me if I'm wrong) that raw term match should not make use of any analyzing, stopword filtering etc
operator: andto non fuzzymatchqueries, this doesn't do anything tomatch_phrasebut this should already improve matching quite a bitReferences many "component: search" issues. What I tested with a
database of all public add-ons:
Example searches:
tab center redux- should find "Tab Center Redux" while "Tab Mix Plus" is probably second and "Redux DevTools" 4th or soOpen Image in New Tab-> should find "Open Image in New Tab" while "Open Bookmarks in New Tab" should be 2nd or 3rdCoinHive-> Finds "Coinhive Blocker", "CoinBlock" (prefix search) and "NoMiners" (description)Privacy-> Finds "Privacy Badger", "Privacy Pass", "Privacy Settings", "Google Privacy" (probably 4th or so) and "Blur" (summary + description + many users). Scores "Ghostery" on the first page but ranks it in the middlefirebu-> Finds "Firebug", "Firebug Autocompleter", "Firefinder for Firebug"fireb-> Scores "Fire Drag" first, puts "Firebug" approximately 3rd or soMenu Wizzard-> Finds "Menu Wizard" (fuzzy, typo) first, then "Add-ons Manager Context Menu" apparently because it matches good in the title and has many usersFrame Demolition-> Finds "Frame Demolition"Demolition-> Finds only "Frame Demolition", same for "Demolation" (typo)reStyle -> Finds "reStyle" and scores a few add-ons that match on "restore" next since the term is similar
MegaUpload DownloadHelper-> finds "MegaUpload DownloadHelper" first, scores "Video * DownloadHelper" and "RadpidShare DownloadHelper" next. Doesn't find "Popup Blocker" anymore as currently happening on -prodMegaUpload-> only finds "MegaUpload DownloadHelper" and nothing elseNo Flash-> Scores "No Flash" first, then depending on users "Download Flash and Video", "YouTube Flash Video Player" and "YouTube Flash Player" (not necessarily in that order)Disable Hello, Pocket & Reader+ -> finds "Disable Hello, Pocket & Reader+" first (yeay!), then scores "Reader", "Disable WebRTC" and "In My Pocket" next similarly to what's happening on -prod currently
Please note that these are more "Guidelines", actual results in production may differ depending on shard configuration and document spreading. We might want to think about using https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-search-type.html#dfs-query-then-fetch which doesn't sound too bad imho, might hurt performance though. One step at a time.
Not working yet:
Not sure if it's specifically only because of these changes but mozilla/addons#3378 is fixed.
This potentially fixes mozilla/addons#5141, mozilla/addons#5004, mozilla/addons#4977, mozilla/addons#4778, mozilla/addons#359.
Not sure if this fixes mozilla/addons#567 but the results look much more promising and the amount of results doesn't explode here. I only have 2.8k add-ons for testing though so I'm not too sure.
And might be relevant to mozilla/addons#4652.
This is a big step towards mozilla/addons#3097, I doubt we can call this fixed though.
Script used to download public add-ons locally and test above searches: https://gist.github.com/EnTeQuAk/7f74c3018466bbffbaa4427842a451f8
As a next step we could try making the
(query.Match, {'query': search_query, 'boost': 3, 'standard', 'operator': 'and'})part amustinstead of linking it all together with ashould. But that's just a random thought.