I don't know if this is a problem with facetapi or search_api_db. I've made a search using views, search_api, search_api_db and facetapi.

You enter terms for the fulltext search in a text box, and then there are facets corresponding to categories. I will try to write a simple example to describe the questionable behaviour:

Suppose I have a node with the title "dog owners" and a node with the title "cat owners".
"dog owners" is in the category "dog" and "cat owners" is in the category "cat".

If I search for "dog" I get the "dog owners" node and the facets show "dog (1)". This is as expected.

If I search for "cat" I get the "cat owners" node and the facets show "cat (1)". This is as expected.

If I search for "owners" I get both of the nodes, and the facets show both of those facets. This is as expected.

If I search for "cat owners" I get the "cat owners" node and the facets show "cat (1)". This is as expected.

If I search for "dog owners" I get the "dog owners" node (as expected), but the facets show "cat (1)". This is NOT correct. If I click on "cat (1)" there are no results and no facets appear. It shouldn't be possible for this to happen.

I've been through the settings and there doesn't seem to be anything I can change, and from looking at the queries it produces I don't fully understand what it's doing. The queries seem to use OR to combine terms in the search, which would suggest that searching for "dog owners" should also find the "cat owners" node since it contains the word "owners". But that doesn't happen in the search results, but maybe facets thinks it does? But if you click on the facet, you get no results and the facet disappears, suggesting it doesn't. Something isn't right here.

Comments

rob230’s picture

Status: Active » Closed (fixed)

This is a bug with search_api_db that is fixed in the latest dev version. See #1403916: Multi word search results sets incorrect count for search_api_facets when Facets is in use.