Hey there,

The widget works great now which is amazing!

However, I was wondering if you could add some sensible (configurable) limits for the minimum number of characters to search by and the maximum number of candidate results to display.

In effect, I would like to avoid situations where a user has typed in just 1 letter and gets a list of 100 autocomplete options in return.

Thanks in advance!

Cheers

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Vacilando’s picture

Priority: Normal » Major

I absolutely agree. Not only because there may be too many matches, but because with larger data sets PHP runs out of memory.

E.g. I started typing a word a bit too slowly and after the first letter a JavaScript popup appeared saying
An HTTP error 503 occurred. <br />http://MYDOMAIN.TLD/autocomplete_filter/MYVIEW
AND I noticed a PHP Fatal error in the log (even with huge memory allocation):
[Thu May 12 14:58:52 2011] [error] [client 127.0.0.1] PHP Fatal error: Allowed memory size of 402653184 bytes exhausted (tried to allocate 99 bytes) in /MYPATH/includes/database.mysqli.inc on line 164

A sensible limit, whatever it may be, would be great, but a limit that could be specified in the settings would be ideal. Thanks!

vasike’s picture

i'll think about the minimum 2 characters. Maybe it's the logic way.
1 i think 2 it's about nothing.

Anyway, i think this should be used for fields that have some values that repeate.
I think it's not a solution for fields that have a very lot and uniques values.

arski’s picture

hey there,

I think that the duplicate values thing is a separate issue - it would certainly be nice not to have duplicates in the autocomplete, because they're pretty useless there.

to be honest, I would be against 2 characters because for fields with some sort of numeric ids that can still result in a lot of options.. e.g. between 10 and 1000, any 2-digit combination appears around 20 times.. which is already too much in terms of usability and 1000 is not even a high id for something..

to be honest somebody will always argue for a different limit value etc, so really a views filter setting would be soooo ideal :)

Vacilando’s picture

@arski, you are right, removing duplicates would help greatly as well. It's possible that my current problem (PHP fatal error because of exhausted memory) could be solved by that already.

An attempt to summarize the topic of this feature request, and prioritize:

1) Make sure that the returned values are unique (remove duplicates).
2) Add configuration field for minimum number of characters, making the default minimum "2" (few would want to autocomplete one letter)
3) Add configuration field for maximum number of returned values.

Thank you for your excellent work, @vasike!

vasike’s picture

thanks a lot for the support
The values are unique for sure

About the others ones i can't promise that will be so soon.

Any (working patch) help wil be publish :)

robbertnl’s picture

You are using the built-in autocomplete.js. This means you have to modify the autocomplete script to change the behaviour or write your own autocomplete code

Dmitriy.trt’s picture

Version: 6.x-1.x-dev » 6.x-1.2
Status: Active » Needs review
FileSize
9.8 KB
15.91 KB

Made almost complete rewrite of 6.x-1.2 version based on original ideas with following benefits:

  • Autocomplete suggestions depending on values of other exposed filters (optional).
  • Ability to select field for suggestions. There is no more requirement about the same field for filter and suggestions.
  • Configurable maximum number of suggestions (the only modification related to this issue).
  • Options to use RAW field data or rendered field output.
  • Additional checks to prevent fetching autocomplete suggestions on any field by hand-writing URL of request.
  • Disable view cache when retrieving autocomplete suggestions.
  • Use views API instead of determining default/overridden options manually.

Please, let me know how can I help to merge these changes into upstream project. I'm attaching both patch from 6.x-1.2 version and full module, because not much code left untouched.

Dmitriy.trt’s picture

Here is an updated version. Limit actually works now. Previous version had 10 items limit forced (and probably other problems) because of missing pre- and post-execute view processing.

vasike’s picture

many thanks
i sincerely don't know if i'll have time soon to check, but i trust the community.

so if the feedback/reviews are positive i surely replace the module

Dmitriy.trt’s picture

Version: 6.x-1.2 » 7.x-1.x-dev
Priority: Major » Normal
FileSize
4.34 KB
19.36 KB

Ported all changes described earlier to 7.x-1.x version. Also, added handler validation to be sure there is a field selected on view save and implemented access check on autocomplete path.

populist’s picture

I did a quick review of the patch in #10 and it works for my use cases in the -dev version of the Drupal 7 module.

The major piece of feedback I have is that it only seems to work for field based views and won't work for node based views. This might be solvable by switching $view->display_handler->options['row_plugin'] to 'fields' prior to running the autocomplete.

vasike’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev

thank you all for the support, especially Dmitriy.trt, thank you Sir for your work (great one).
sorry about delay.
here is the commit for the 7 version : http://drupalcode.org/project/views_autocomplete_filters.git/commit/c31b7f0

with this big change, i create the first beta release (thanks populist for your insistence).

now backport to 6 is needed.
is there anyone to confirm the patch for 6?

colan’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)