The autocomplete result list does not always return a complete list of matches. This bug is similar to https://www.drupal.org/node/1430418#comment-5776092
You're attempting to limit the number of options to 10, but what is actually happening is that you've limited the number of records returned by the query to 10 -- the first 10.
To demonstrate, create a view on a large dataset with many duplicated values. Add an exposed filter with Autocomplete enabled. The pop-up autocomplete list will contain fewer than the requested number of results, depending on how many unique values appear in the first n rows of the view result.
Comment | File | Size | Author |
---|---|---|---|
#9 | views_autocomplete_filters-autocomplete-returns-incomplete-results-bug-2483413-9.patch | 849 bytes | mitjasvab |
Comments
Comment #1
ikeigenwijs CreditAttribution: ikeigenwijs commentedI also stumbled in to this problem.
We have a short list of distinct values less than 200 but on 20k rows.
In query terms this should be no problem.
Setting the maximum number to return to 0 == no limit.
Gave no better result and longer waiting times.
Large php memory footprint and cascading Ajax errors
setting the minimum length when starting autocompleet did not help.
Comment #2
NWOM CreditAttribution: NWOM commentedI'm sadly having the same issue. I'm using an autocomplete on around 8000 entities, and it doesn't pull all of the results. If I change the filter back to a normal non-autocomplete filter, all results can be searched as expected.
For example, if I search for "Ra", it shows no results, but if I search for "Ab" it works. So it appears to stop after a certain number of entities.
Comment #3
NWOM CreditAttribution: NWOM commentedComment #4
NWOM CreditAttribution: NWOM commentedComment #5
NWOM CreditAttribution: NWOM commentedFor me setting "Maximum number of items in Autocomplete results" to "0" did not help either
Edit:
I was able to isolate the issue even more. If I filter the view manually to include less results, the missing results are then shown in the suggestions as expected.
Comment #6
ikeigenwijs CreditAttribution: ikeigenwijs commentedTried the suggested sollutions here:
http://drupal.stackexchange.com/questions/101781/control-number-of-autoc...
http://drupal.stackexchange.com/questions/68566/how-to-show-all-autocomp...
But with no success
Comment #7
Genu CreditAttribution: Genu commentedThis bug is due to the method used by the plugin to retrieve suggested values for auto complete.
It happens when you add a limit on the number of suggestions.
Let's assume we choose to set up a 10 suggestions limit.
To retrieve 10 suggested values, the view is executed and the 10-limit is applied on the view result. So, if results 1 to 10 of the view have only 1 single distinct value for the field used in autocomplete, you will get only 1 suggestion.
This is done in views_autocomplete_filters.inc, with the pager defined at line 115. You can see in following lines that the view is simply executed, and results read to build suggested values.
To fix this, the module should use an altered version of the view. It should:
The code to do that has to be inserted between the pre_execute and the execute of the view :
Now, the query will do a "select distinct" on the fields used to build the suggest results. The page will limit on distinct values, so you will have exactly the desired number of suggested values. And since your query is focused only on needed data, performance are clearly better.
Comment #8
petrovichby CreditAttribution: petrovichby commented#7 worked for me. Thanks.
Comment #9
mitjasvab CreditAttribution: mitjasvab as a volunteer and commentedHi,
I just assembled the patch #7 in a patch file. For me it is working too, so I set to Reviewed & tested.