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.
I am trying to use hook_views_query_alter, to modify an exposed filter value in a Search API Index view. It is a field collection item field. Any help in getting the query field would be welcome.
Thanks, in anticipation.
Comments
Comment #1
drunken monkeyUse
hook_search_api_views_query_alter()
instead. Seeincludes/query.inc
in the Search API Views module for the definition of the views query class.$query->getSearchApiQuery()
gives you the Search API query object. Seeincludes/query.inc
in the Search API module to see what you can do with that.Comment #2
alamp CreditAttribution: alamp commentedHere is the output of dpm ($query->getSearchApiQuery());
Comment #3
drunken monkeyFirst off, this looks much more like
dpm($query);
If it is reallydpm ($query->getSearchApiQuery());
, then there is a weird bug there.Second: What do you want to say with this? Is it good, bad, do you want help or do you want to help?
Comment #4
alamp CreditAttribution: alamp commentedIt is kind of you to correct something wrong if it is not true.
I just posted it for someone who might have an interest in the value of
$query->getSearchApiQuery()
.Comment #5
pritamprasun CreditAttribution: pritamprasun commentedHow can we do groupby here like $query->add_groupby('nid'); in hook_vews_query_alter() ?
Comment #6
drunken monkeyIt's possible to do something similar by using the Search API Grouping module (though that works globally on all searches for the index) with Solr. (Or by using the same query options manually.)
Other than that, grouping isn't supported by the Search API.