Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete suggestions limited to 25: not enough! #465

Closed
monsieurtanuki opened this issue May 18, 2022 · 7 comments · Fixed by openfoodfacts/openfoodfacts-server#6887 or #498
Closed
Assignees
Labels
autocomplete 🐛 bug Something isn't working

Comments

@monsieurtanuki
Copy link
Contributor

Describe the bug

  • Method getAutocompletedSuggestions takes a taxonomy type and an input arguments (and a language).
  • It returns all the taxonomy values from this type, and that match the input.
  • The problem is that only 25 items max are returned, which can be problematic with common terms.

To Reproduce
Steps to reproduce the behavior:

  1. Look for "soja" in French - go to https://world.openfoodfacts.org/cgi/suggest.pl?tagtype=categories&term=soja&lc=fr
  2. You'll see only 3 results that match "Boissons végétales de soja"
  3. Look for "Boissons végétales de soja" in French - go to https://world.openfoodfacts.org/cgi/suggest.pl?tagtype=categories&term=Boissons%20végétales%20de%20soja&lc=fr
  4. You'll see 6 results that match "Boissons végétales de soja"

Expected behavior

  • We would expect the 6 "Boissons végétales de soja" to be returned with the mere "soja" search.
  • We could expect an additional parameter to go beyond 25 returned items.
  • We could expect an additional returned value that gives the total number of items that match.
  • That makes the method a bit difficult to trust, because it also expects a perfect match, and unless you're a genius you cannot imagine it should be "Boissons végétales de soja", "Boissons à base de soja" or "Boissons végétales au soja"
  • Therefore we cannot realistically use that method IRW - I found the bug during unrelated tests.

Additional context
The problem obviously comes from the server, where $limit = 25 forces the max result length.

@M123-dev
Copy link
Member

M123-dev commented Jun 6, 2022

We should then probably move this issue to the server repo

CC @stephanegigandet

@stephanegigandet
Copy link
Contributor

@alexgarel will look into it, we could add an option to set the number of desired results. Also we could split the input query so that "boisson soja" matches any category with the 2 words "boisson" and "soja".

@monsieurtanuki
Copy link
Contributor Author

@stephanegigandet Both ideas would be appreciated.

The next level would be to return a json object instead of just a list, with more detailed fields like the total number of matching items (e.g. count). But that's another story.

@alexgarel alexgarel self-assigned this Jun 6, 2022
@alexgarel alexgarel moved this from 🔖 Sprint (max 10) to 🏗 In progress in Product Opener - Sprint Jun 10, 2022
@alexgarel
Copy link
Member

I started looking at it.

The problem is that our suggestion is iterating the list, always in the order of the keys which might not be relevant at all ! (we might first get term that does not start with the term, etc.)

As our search is not indexed and only use brute force iteration, it does not seems like a good idea to process whole list every time…

@alexgarel
Copy link
Member

I pushed a PR, but it's just a quick fix… I think in the future a search index could do a far better job.

@monsieurtanuki
Copy link
Contributor Author

Thank you @alexgarel for that quick fix!
Once it's merged we'll see if there are hidden use cases we forgot.

@alexgarel alexgarel moved this from Sprint (in priority order, max 10) to In Progress in 🍊 Open Food Facts Server issues Jun 13, 2022
Repository owner moved this from To discuss and validate to Done in 🤳🥫 The Open Food Facts mobile app (Android & iOS) Jun 13, 2022
Repository owner moved this from In Progress to Done in 🍊 Open Food Facts Server issues Jun 13, 2022
@monsieurtanuki
Copy link
Contributor Author

@alexgarel We still have to code it in dart!

Repository owner moved this from Done to In Progress in 🍊 Open Food Facts Server issues Jun 13, 2022
@alexgarel alexgarel moved this from 🏗 In progress to To verify (preprod) in Product Opener - Sprint Jun 13, 2022
@alexgarel alexgarel moved this from To verify (preprod) to ✅ Done in Product Opener - Sprint Jun 13, 2022
@monsieurtanuki monsieurtanuki self-assigned this Jun 24, 2022
monsieurtanuki added a commit to monsieurtanuki/openfoodfacts-dart that referenced this issue Jun 26, 2022
…estions

Impacted files:
* `api_get_automcompleted_suggestions.dart`: additional test about the new `limit` parameter.
* `openfoodfacts.dart`: new `limit` parameter for autocomplete suggestions.
monsieurtanuki added a commit to monsieurtanuki/openfoodfacts-dart that referenced this issue Jun 26, 2022
Impacted file:
* `api_saveProduct_test.dart`
monsieurtanuki added a commit that referenced this issue Jun 29, 2022
Impacted files:
* `api_get_automcompleted_suggestions.dart`: additional test about the new `limit` parameter.
* `api_saveProduct_test.dart`: unrelated test skip
* `KnowlegdePanelElement.dart`: `title` is now optional
* `KnowlegdePanelElement.g.dart`: generated
* `openfoodfacts.dart`: new `limit` parameter for autocomplete suggestions.
Repository owner moved this from In Progress to Done in 🍊 Open Food Facts Server issues Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment