1

I am building a small website for a charity and am trying to integrate search_api to search the list of projects.

I have a content type named "Project" with the following fields:

  • Title ( Project Name )
  • Body
  • Project Image ( Image field )
  • Project Countries ( Multi valued taxonomy of all Countries this project operates in )

I need to build a search page that has:

  • A free text search box that will search Title/Body as a fulltext search
  • A select list or autocomplete field that allows you to select the country you are searching

So far I have:

  • Created a new solr search server using search_api
  • Indexed the Project content type in a new search index
  • Added all taxonomy values and fields to the search index ( in the hope one would work )
  • Created a view linked to this index
  • Added all of the above taxonomy fields as exposed group search filters but none of them pick up the values of the taxonomy.

I can happily freetext search on the indexed fields but if I want to use dropdown filters or even checkboxes to filter the results it just doesn't work.

Clearly I am doing something wrong here, what is the best way to achieve what I am trying to do?

3

In this case I would create a Facet. You'll need to enable Search Facets (shipped with Search API) and Facet API.

Once you have that in place go to Configuration -> Search and metadata -> Search API and click edit on your Search index. In the dropdown there is a new choice called Facets now.

enter image description here

Enable the facet for you field Project Countries. That field also needs to be indexed under your fields settings for your search index. Facet API will provide a block for you with the Facet that you need to place on your search page.

Facets work in a way that they only show options available in your search result. If "Sweden" is not present in the field Project Countries in any of the nodes you have indexed it will neither be available in the Facet. So facets work in a way that they narrow down search results and usually doesn't show options that will result in an empty search. That's the biggest difference I see between a facet and a normal filter in Views.

Facets are normally displayed as checkboxes or links (see display settings for your Facet). You mentioned in your question that you have it now in the View as a dropdown. You you want to keep it as a dropdown instead of checkboxes / links you could checkout Facetapi select

0

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.