I have verified that this module is enabled and it is working when i create a test view with normal fields.

However when trying to enable auto complete on a view of indexed nodes (search api) the use autocomplete box is not available on the exposed filter (see attached screenshot)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chrism2671’s picture

+1

chrism2671’s picture

Category: support » bug

I'm trying to hunt down the cause of this- a quick scan of the code suggests it *should* work, just need to persuade it.

T.Mardi’s picture

Same issue here. I can't get the option to use autocomplete functionality on indexed fields using Search API.

Did you have any luck getting it to work?

chrism2671’s picture

I did investigate but it requires a fair bit of fiddly rearranging to make it work; I haven't got time to look at it at the moment I'm afraid.

T.Mardi’s picture

No problem. I've noticed a autocomplete filter in use here using Facet API.

Will look into this to and reply back if I find a solution.

vivdrupal’s picture

Request to the maintainer - vasike

Could you please check if it is possible to use the module with indexed fields of Search Api?

Badly need this feature. Thanks.

vasike’s picture

for the Search API could you try use Search API autocomplete.

this waht is used in the example given at #5.

vivdrupal’s picture

@vasike
Thanks for your response.
Ended up using the 'Chosen' module.

narkoff’s picture

I also am looking to get this working with indexed fields of Search API. I am currently using Search API Autocomplete, but it does not have some of the features of Views Autocomplete Filters and, more importantly, does not retrieve "complete" suggestions.

For example, if 'Los' is entered in exposed filter for Title field, Search API Autocomplete only returns matches for a word in the title field that starts with 'Los'. However, it does not return 'Los Angeles' as a suggestion. It appears that Views Autocomplete Filters will return suggestions that include the whole Title field, not just the single word that starts with the characters entered in the exposed filter.

Returning the complete field as the autocomplete suggestion, and not just the single word that contains the match, is the behavior I'm looking for.

dureaghin’s picture

Issue summary: View changes

Hi narkoff,
Did you figure out how to use "complete" suggestions?

Thanks.

narkoff’s picture

@Hakintosh,

I could not get Views Autocomplete Filters to work with my Search API indexed fields correctly. I did work with Search API Autocomplete module a bit. It works on indexed fields, but I still could not get the returned suggestions to be how I wanted. There were either stemming issues or the complete field would not be returned. I did get close by trying different Solr filter classes in the schema_extra_fields.xml. This thread gives more detail.

However, I ended up using the Search Autocomplete module. It works with Search API fields and I am getting the complete field to be returned as a suggestion.

NWOM’s picture

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

This seems to be a problem also in the newest dev (not sure if feature or bug). The potential workaround using the Search Autocomplete sadly only works with keywords currently, and isn't the best use case when wanting to only show Entity Titles as an example.

dsnopek’s picture

The reason this doesn't work, is that views_autocomplete_filters_views_data_alter() is swapping in the autocomplete handler for only views_handler_filter_string and views_handler_filter_combine:

/**
* Implements hook_views_data_alter().
*/
function views_autocomplete_filters_views_data_alter(&$data) {
  foreach ($data as $data_type => $data_fields) {
    foreach ($data_fields as $fieldname => $data_field) {
      if (isset($data_field['filter']['handler'])) {
        // Extend the basic textfield filter handler with autocomplete.
        if ($data_field['filter']['handler'] == 'views_handler_filter_string') {
          $data[$data_type][$fieldname]['filter']['handler'] = 'views_autocomplete_filters_handler_filter_string';
        }
        // Extend the multiple fields search filter handler with autocomplete.
        elseif ($data_field['filter']['handler'] == 'views_handler_filter_combine') {
          $data[$data_type][$fieldname]['filter']['handler'] = 'views_autocomplete_filters_handler_filter_combine';
        }
      }
    }
  }
}

But the indexed fields use handlers that appear to come from the Entity API module, like entity_views_handler_field_text.

Here's some of the views data I print_r()'ed for the node 'title' field, and a random long text field:

[title] => Array
(
    [title] => Title
    [help] => The title of the node.
    [field] => Array
        (
            [handler] => entity_views_handler_field_text
            [type] => text
        )

    [type] => text
    [argument] => Array
        (
            [handler] => SearchApiViewsHandlerArgumentString
        )

    [filter] => Array
        (
            [handler] => SearchApiViewsHandlerFilterText
        )

)


[field_long_text_value] => Array
                (
                    [title] => Long text » Text
                    [help] => (No information available)
                    [field] => Array
                        (
                            [handler] => entity_views_handler_field_text
                            [type] => text
                        )

                    [real field] => field_long_text:value
                )

In order to get views_autocomplete_filters working with these fields, we'd need to have a views handler that we could swap in for that, which would support the Entity API way of doing views handlers, while also adding the autocomplete functionality.

vasike’s picture

Category: Bug report » Feature request

This is not a bug, but a feature request
as it was not implemented yet - see previous comment.

@dsnopek : thank you.

mascot’s picture

Is there a work around to handle this....any suggestions could be of great help

  • vasike committed 002cb59 on 7.x-1.x
    Issue #2057949 by vasike, dsnopek: Not working for views based on...
vasike’s picture

Status: Active » Needs review

there is first implementation committed.
so anyone that could help testing the dev version of the module, please.

thanks

zied.ellouze’s picture

@vasike I have tested the dev version and it not works :(

Thank you

narkoff’s picture

@vasike, regarding #16 commit - Testing an indexed view (Search API):

1. Editing the view's exposed filter now has an 'Use Autocomplete' checkbox which when enabled, several additional options flex in:
a. Maximum number of items in Autocomplete results.
b. Suggestions depend on other filter fields.
c. Field with Autocomplete results.
d. Unformatted dropdown and unformatted suggestion checkboxes.

2. The view's exposed filter now generates a throbber when entering a value in the filter. However, no suggestions are returned. No console errors are generated and the requested URL is: <site.com>/autocomplete_filter/search_api_views_fulltext/<view name>/<display name>/0/<value entered in exposed filter>

I've tried different settings but can't get any suggestions to be returned.

UPDATE: The option 'Field with autocomplete results' is a dropdown, but only value I get is the default 'Add some fields to view'. I've tried adding some fields to view, but the dropdown still only has the default/empty value. Is a value required to be selected in this dropdown in order to get any suggestions returned in the autocomplete exposed filter?

UPDATE 2: The only type of field I can get to populate in the 'Field with autocomplete results' dropdown is a taxonomy term field that is indexed in Search API. When populated, the autocomplete functionality works in the exposed filter. However, I can not get it to work for any other type of fields.

jenlampton’s picture

Status: Needs review » Active

Setting status back to Active since it sounds like we could still use some refinement for what's been committed to the latest -dev.