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

anderson_rioba’s picture

Issue summary: View changes
anderson_rioba’s picture

Project: Search API Database Search » Search API
Version: 7.x-1.x-dev » 7.x-1.2
Component: Code » Framework
drunken monkey’s picture

Category: Task » Feature request

Yes, it is possible – you can implement your own query class (subclass of SearchApiQuery) that adds an additional parse mode for doing this (see parseModes() and parseKeys()).
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 from query(). Implement hook_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 in includes/query.inc saying we should add that.

legolasbo’s picture

Status: Active » Closed (outdated)

This 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.