7

I just today decided to try out using Search API instead of just the regular exposed filters within views. However, even with the Search API Views module enabled, my indexes don't appear to be exposed to Views as filters. Documentation on integrating Search API and Views is relatively non-existent, so I can't really go to that for help. In fact, the documentation for the integration module states that "Most features should be clear to users of Views." Well apparently not. Any help would be appreciated.

  • I assume you established database search server and then an index. Have you also watched the screencast on using Views and creating a "Node index" view? That helped me a lot. – Artur Jun 16 '12 at 21:15
  • I have set up the server and an index, but I'll take a look at the "node index" screencast. Would you happen to have a link to it? – Mrweiner Jun 16 '12 at 21:20
  • Did anyone find a link to that screencast? – zrajm Jul 10 '13 at 19:50
  • – Is it the Vimeo Search API Screencast 2010-09, perchance? – zrajm Jul 10 '13 at 19:56
3

You have first to connect to the server and, then, create an index. So when you click to "add view" you have to choose what kind of view: contents, taxonomies, users or the index you have created. At this point you have field and filters from the search api index (you have to choose which fields should be indexed). Have you a solr server or you want to add a "simple" mysql server to search api?

  • I actually did end up getting this figured out a while ago, and forgot I had posted this. But, this definitely would have helped out before! :) I ended up setting up a database index for now. Solr is more than I need at this point in time. – Mrweiner Jul 25 '12 at 17:21
  • Info on how to create a search server and index: drupal.org/node/1597930 – zrajm Jul 10 '13 at 19:48
14

The important points, which I can't seem to find stated clearly anywhere:

  • Each Search API search index you create becomes an option in the "Show [content]" dropdown at the top when you first create a new view. Unlike regular search views (where you could just take any old view and add a "Search" contextual filter), to use search API in views, you have to create a special type of view, choosing and fixing the search index to use at the point of creating the view, by choosing it in this dropdown.
  • You'll need to pipe the actual search terms in somehow. A common way is to use the "Search fulltext" contextual filter, which interprets an argument in the URL as the search terms to use. There's also (depending on search server, I believe) the popular "Search More like this" option, which uses the content of the entity loaded via the contextual filter as the search terms (so if it's a block on a node page set to use the node's nid, it gives you results as if you searched using that node's content). Another way is using an exposed filter then getting the search terms from the input or exposed filter part of the URL query string.
  • For reasons I don't quite understand (probably something to to do with how entity API module does views integration for entity views, which has some limitations, more info at http://drupal.org/node/1378656), some elements of a Search API view are different to how they would be normally. For example, where in a node view, the path would be [path], in a Search API index view on a search index set to search nodes, it's [url]. It's no big deal, mostly the differences are fairly easy to figure out, but it's something to watch out for. Some things e.g. some relationships don't work for similar reasons - test complex views thoroughly and look at both Search API and Entity API issue queues if you find problems.

There is, technically, a documentation page that touches on some of this, which might be of some use to someone.

8

Be sure to have have "Search Views" module enabled. Something which nobody seems to mention is needed in the documentation anywhere.

  • hours debugging why my search index and I was simply missing this step. Thanks!! – Alejandro Moreno May 11 '18 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.