Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is there a way to get all the possible/existing values out of a given facet? I've looked through various parts of the code but not managed to find anything and quickly got out of my depth with realms/searchers/etc.
The reason I'm after this is that I want to make a field type that points to a facet & value combination, to make landing pages that embed search results, or link to them.
Comments
Comment #1
cpliakas CreditAttribution: cpliakas commentedHi joachim.
So the tricky part here is that it is really outside of Facet API's scope right now because the backend is responsible for executing some search, gathering the facet data, and sending it to Facet API. If you are using Solr, there is nothing stopping you from executing an empty search at which point you should have the facet data. Check out the apachesolr_search_init() function, focusing on line 58. The
apachesolr_search_run_empty()
function should initialize the facets for you. If you are using another backend then you will have to ask those maintainers for help, as I am not as familiar with their APIs.Hope this helps,
Chris
Comment #2
marcusx CreditAttribution: marcusx commentedHi @joachim
What was your solution 3 years ago? I have the same problem now. I have a node type I called persistent_search with several metadata and some search results on it. At the moment I store key|values for facetname|item1,item2 in a simple text field. But this will not work with the editors that will create those nodes later. So is there a userfriendly solution for storing facets and some of the possible items already somewhere?
Thanks and Regards
mx
Comment #3
joachim CreditAttribution: joachim commentedSorry, I don't remember at all what we did with this, and I'm no longer on that project so I can't look at the codebase.