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

Autosuggest works erratically if the responses are not received in the right order #719

Closed
teolemon opened this issue Mar 24, 2023 · 5 comments · Fixed by #720 or openfoodfacts/smooth-app#3876
Assignees

Comments

@teolemon
Copy link
Member

Description

  • Reported by @alexgarel, unsure how often it happens
  • If the request for the first character is sent, then the second request with two characters is sent, and the client receives the response of the two-character request and then the response of the one-character request, then the auto-suggestion will occur. behave erratically. The solution to fix the problem is to check the timeline of requests.

Part of

@monsieurtanuki
Copy link
Contributor

Technically it has not that much to do with OFF typical added value.

Theoretically it's quite interesting though. It would be like the combination of a cache of results and the latest typed string.

Currently the suggestions are called each time the user types a new character (or something like that):

                  return OpenFoodAPIClient.getSuggestions(
                    tagType!,
                    language: ProductQuery.getLanguage()!,
                    country: ProductQuery.getCountry(),
                    limit: 15,
                    input: input,
                  );

The displayed suggestions are refreshed by the return statement.
It looks like the problem is when "old suggestions" are eventually returned (a bit too late), they are displayed and therefore bypass the current suggestions.
I would say that in an ideal world that should be dealt with by the Autocomplete widget.

I can code a SuggestionManager to deal with that. Should it be in OFF-dart or in Smoothie, that's another story.
Let's try with OFF-dart first.

@monsieurtanuki
Copy link
Contributor

@stephanegigandet Just curious: have suggestions evolved recently?
Our previous tests said something like "if you type 'M', then all the suggestions will contain 'M'".
But it does not seem to be the case anymore.
Doesn't look that bad, for instance "Guyane" is suggested from "FR".
Should we then avoid the "'M' in input means 'M' in suggestions" tests in off-dart?

@stephanegigandet
Copy link
Contributor

@monsieurtanuki We now also return taxonomy entries that have one of their synonyms match the input string, even if it doesn't match the main name of the entry. e.g. for countries, we will also match country codes, so looking for "fr" also returns the Faroese Islands because they have the country code FRO.

https://world.openfoodfacts.org/api/v3/taxonomy_suggestions?tagtype=countries&string=fr

Same for "us", we return "United States" and "Soviet Union" (which matches "USSR"): https://world.openfoodfacts.org/api/v3/taxonomy_suggestions?tagtype=countries&string=us

In the future, we might adjust the filtering and ranking of some taxonomies, based on context, popularity etc. like we do for packaging shapes and materials.

@monsieurtanuki
Copy link
Contributor

@stephanegigandet I understand the concept and I agree with it.

In some cases you guys go too far, to a point where one can suspect something is wrong, for instance looking for "F" countries (https://world.openfoodfacts.org/api/v3/taxonomy_suggestions?tagtype=countries&string=f):

  1. Brazil
  2. Falkland Islands
  3. Faroe Islands
  4. Federated States of Micronesia
  5. Fiji
  6. Finland
  7. France
  8. French Guiana
  9. French Polynesia
  10. French Southern and Antarctic Lands
  11. Germany
  12. Liechtenstein
  13. Nepal
  14. Nigeria
  15. North Macedonia
  16. Saint Kitts and Nevis
  17. Somalia
  18. Afghanistan
  19. Albania
  20. Algeria
  21. Andorra
  22. Angola
  23. Armenia
  24. Aruba
  25. Australia

Probably an issue with "of".

@stephanegigandet
Copy link
Contributor

@monsieurtanuki Right, that's because we have the full official names of countries in the taxonomy as synonyms... We may want to remove those.

en:Algeria, People’s Democratic Republic of Algeria, DZ, DZA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants