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 implement an exlusive search operation in drupal such that if i type a phrase like
"all kinds of wildlife" -lion
I get search results for "all kinds of wildlife" excluding lion ?
Comments
Comment #1
anderson_rioba CreditAttribution: anderson_rioba commentedComment #2
anderson_rioba CreditAttribution: anderson_rioba commentedComment #3
drunken monkeyYes, it is possible – you can implement your own query class (subclass of
SearchApiQuery
) that adds an additional parse mode for doing this (seeparseModes()
andparseKeys()
).However, due to a design flaw in the framework, you then also need to override the service class in question (
SearchApiDbService
I guess, in your case) to return a query object of your class fromquery()
. Implementhook_search_api_service_info_alter()
to change$services['search_api_db_service']['class']
to your new service class.Of course, if you would implement such a thing, I would also be inclined to just add it as a fourth option to the standard query class, so you don't have to do all of that but just implement the parsing. There is actually a
@todo
comment inincludes/query.inc
saying we should add that.Comment #4
legolasboThis issue has not seen activity in over 2,5 years. I am therefore closing this issue to clean up the issue queue. Feel free to re-open and update this issue if you feel this issue is still relevant and of importance.