Hello Miroslav and thanks for the great module.

Before opening this ticket I read all relevant issues but could not find an answer there.

As i understood Search Autocomplete can search for words in node titles (views-->nodes-autocomplete), in body text (views-->words-autocomplete) or in taxonomy terms.

But how can one create a view that searches for everything? That is, search among node titles, node body and taxonomy terms.

Is this even possible taken that our custom view can include only one filter - you mentioned that "the view has to expose one filter to its user". When I try to add 2 filters, I am not allowed to use the same "Filter Identifier (=filter)" and therefore Search Autocomplete stops working.

Thanks in advance for your time.

Comments

pipicom’s picture

Issue summary: View changes
Dom.’s picture

Hi pipicorn,

The issue you expose is more a Views issue than a Search Autocomplete issue in the way that you are looking at how to create a view to make this happen. Once the view is done, this module can handle it's reply.

I actually have talked about it multiple times, but never did a real use case example (I shall -once I got some time- do a poper documentation on the particular topic).
Views is just a way to perform DB request for people without coding skills. But the best, easy and efficient way to do what you want is actually to create a small custom module that would provide a callback URL (though hook_menu).
This callback method will perform all the necessary DB requests to all your necessary informations (nodes, taxonomies, products, users, whatever...) and will generate the json output, compatible with the Search Autocomplete expected syntax.

Once you have created this submodule, you can enable it and configure Search Autocomplete to use this custom callback rather than a view... hence retrieve all the informations you wanted.

Dom.

pipicom’s picture

Thank you Dom for the clear answer.

trenttati’s picture

I recently used a Views "Global: Combine fields filter" to search within two different fields with Search Autocomplete. Using relationships you should be able to pull in all of your entities into a view and use a combined fields filter to search within all of them. The performance hit may be very large depending on how many entities you have.

If you have the ability, Dom's custom module suggestion is the better solution to your question.

dakku’s picture

I am also using the Global: Combine fields filter - works very well.

Dom.’s picture

Could you eventually export the view, so I can make a "HOW-to" in documentation ? Maybe even include it from start at module install !
This is probably the most requested feature / question ^^

dakku’s picture

Dom, good idea. I will roll up something for you

trenttati’s picture

Here are my steps reduced to the bare necessities:

  1. Add fields to your Autocompletion JSON formatted view.
  2. Add a "Global: Combine fields filter" and make it exposed.
  3. In the settings for the Global: Combine fields filter select the fields that you want to be searched under "Choose fields to combine for filtering".
Dom.’s picture

Oww... Sorry I did not understand the scope of this ! Then it is the second most wanted HOW-TO ! First behing "how to find everything within one view : users, taxonomies, nodes, etc..." ! :)

Dom.’s picture

Status: Active » Closed (works as designed)
ressa’s picture

Version: 7.x-4.6 » 8.x-1.x-dev
Status: Closed (works as designed) » Active

Hi @dom. - I think it's very interesting what you write in #2, about a custom module which will allow searching in several fields, not just the Title field. Is there any chance that such a module will at some point be included, if you have the time to write it? :-)

ressa’s picture

I just realized that it is possible to search in the Body field, by updating the autocompletion_callbacks:

WHAT - What to display in Search Autocomplete suggestions?
Choose which data should be added to autocompletion suggestions.

FROM: autocompletion_callbacks_nodes::nodes_autocompletion_callback
TO: autocompletion_callbacks_words::words_autocompletion_callback

But I find the behaviour is a bit strange - to get a node listed in the suggestion list, I have to type the exact word...

Is it not possible to get a more "Google"-like effect, so that if I start writing for example "eco", it will suggest "ecology", "economics","economy", and so on?

W01F’s picture

I'm also very much interested in allowing my users to search for content either by node title or body body content AND other users via the same search bar. Currently they can only search for content via keywords in the node title - I also found the words behavior fairly unhelpful as the contained terms had to be an exact match to bring up results. And to search for users they have to go to a completely different views directory page I set up with an exposed filter for username.

I'm not well versed enough to code the module for this myself, but would find (as I recon many others would) such an all-encompassing search option module extremely useful.

syammohanmp’s picture

See the below structure

Content type: College
Field Category: Music, Media, etc
Field Country: US, UK, Canada, etc

How can I get the below autocomplete suggestions.

College for Music, College for Media, etc , Music College in Uk ?

Dom.’s picture

You should write a custom callback for this.
Here is an example for it :
https://www.drupal.org/project/search_autocomplete/issues/3200019#commen...

lubwn’s picture

I used Search API to query all the content types / users / taxonomies I wanted to search for and then created a view of this search api indexed fields, adding "autocomplete callback" as json output and it looks like it works. You can even group those together to create a nice output on autocomplete.

Only downside is you need to have the fields indexed, leading to bigger database but also I guess faster search times realtime.