I have some facet 'blocks' used to filter nodes based on their taxonomy terms. The field attached to my content type is optional, so some nodes are assigned terms and others are not.

Most of these blocks work as expected, but all of the facet blocks for one of my content types have a '0' term available. Selecting this facet filters the search to nodes that haven't got a term selected.

Has anyone else had this issue and could point me in the right direction of how to fix it? I've checked field_x table in the database and there doesn't appear to be any records with zero IDs.

Any help would be greatly appreciated. Please let me know if you need any other details.

Comments

drunken monkey’s picture

Status: Active » Postponed (maintainer needs more info)

Do you still have that problem (also with the latest dev versions of all modules)? There were some fixes regarding NULL values.

Also: Is the field multi-valued? What backend are you using (Solr, DB, …)? Have you checked the Add facet for missing values option for the facet?

St_B’s picture

Version: 7.x-1.x-dev » 7.x-1.11
Category: Support request » Bug report
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

Hi drunken monkey,
I've got the same problem (don't know if I have to post here or in FacetAPI issues, so I did both : 2071881).
I am using Search API 7.x-1.11 with Database search 7.x-1.2 and FacetAPI 7.x-1.3.
The "Add facet for missing values" is on "no" position (I tried "yes" to be sure, nothing changes), however when the field is indexed as a string, I always have a facet row for empty fields. The fields I am using in facets are not multi-valued.
Could you help me to solve this problem ?
Regards
Stéphanie

drunken monkey’s picture

Are there empty values in the field? How do the empty facets look, do they have an empty string as label or "empty"/"none"?
But if the value internally is an empty string, rather than NULL, then I guess this is expected behavior. There's nothing really that makes an empty string less of a "proper value" than any other string. If the field in question is added by contrib, than the bug might be there and they should use NULL for empty values instead of empty strings.

St_B’s picture

This facet is for empty strings, you're right : null are well filtered.
This happens :
- when nodes are imported (here, biblio nodes, imported by batch, with https://drupal.org/project/biblio), a field without any value is null in the DB => not in the facet
- but when a node is created by a user, the field is an empty string. => in the facet
For me the option "add a facet for missing values" should deal with the 2 cases : null or empty string. Don't you think so ?

drunken monkey’s picture

Status: Active » Closed (won't fix)

For me the option "add a facet for missing values" should deal with the 2 cases : null or empty string. Don't you think so ?

I don't know. While treating them the same might be correct in some cases, it will be wrong in others and if I have to decide between the two, I'd rather not work around flaws in the data. The fault here is probably Drupal's, for not handling empty values predictably.

Also, more importantly, all backends I know of make that distinction, too, and especially with Solr it would be very hard to support your proposed handling.

Therefore, I think this should be "won't fix". Please fix your data to fix the facets.

St_B’s picture

ok thank you for your answer !