This issue is complicated to explain. But I'll do my best.
Not sure if it's a support request or a bug.
I got a seriously advanced and custom search page with facets.
On that page I do several search api queries to build my page.
Now I got the issue that the facets only appear if the index that is linked to the facets is called first.
But I need another query first, because I use that output to build a filter for the *main* query.
It's that main query that has the filters I need to show.
When debugging the query I saw the facets gets build perfectly and the facets get build but somehow they don't "popup".
I tried debugging the facet api block code but I failed.
Is this a support request? A bug? Facet api problem?
Any help would be appreciated. I can do some digging myself but I need some guidance at this moment...
Comments
Comment #1
aspilicious commentedA bug report for search api after all. After 6 hours of debugging I finally found the cause :D.
It's located in the search_api_facetapi module. The query type term plugin contains following logic.
I'm not sure *how* everything works but 'search_api_curent_search' always contains an array keyed as follow
SearchApiQuery
SearchApiQuery-1
SearchApiQuery-2
Search ID in my case always return "SearchApiQuery". So it alway will use the first one. In my case however the valid current search is placed second, under the key "SearchApiQuery-1".
Changing the key to SearchApiQuery-1 make my blocks appear again! :D
BUT thats just an ugly hack, is there a proper fix possible?
Comment #2
drunken monkeyAh, good to hear you were able to debug this!
Before I look into it, could you just ensure that you don't have the facets configured to run for the
SearchApiQuerysearch?(Also, if you are programmatically executing searches, it's a good idea to always set the
search idoption to something meaningful, precisely for this reason. Otherwise, this will go wrong if the order of execution changes, or the third query is sometimes the only one executed.)Comment #3
aspilicious commentedYeah there is only one query that has facets configured.
How do I set the search ID? Can't find a method that does that.
Comment #4
drunken monkeyGet it with
$query->getOption('search id'), set it with$query->setOption('search id').And you are sure that in the facet display setting, you have "Display for searches" and "Search IDs" set in a way that will only activate them for the
SearchApiQuery-1ID? (You'll have to change that, of course, when you change the search IDs you are using.)Comment #5
aspilicious commentedWhere can I find those settings? I clicked around everywhere but can't find them? Configure display doesn't show me that?
*feels he is almost there*
Comment #6
aspilicious commentedWhoaha! Setting the search_ID was enough....
o_O
Thnx!
Comment #7
drunken monkeyNo problem, glad it worked.
Comment #8
yusufsarac commented@aspilicious
Can you share your code about how you created facet blocks for your custom query page. I'm trying to make similar thing.
I have a custom query page created by apache solr module's API. I want to create custom facet blocks for that query. But I think facet API facets pull information from original "apache solr" default query.
How can I alter that ?
I asket this here and here
But no luck so far