Opensolr Search for Drupal 5.0.4: Search Operators Work With AI Search On

· Drupal Module · Bug Fix · All updates

Opensolr Search for Drupal 5.0.4 makes the search operators work with AI search switched on. Typing -refurbished now removes refurbished results, +laptop makes that word mandatory, and quoted phrases match as phrases — with the AI toggle in either position.

01 What was wrong

+ and - are ordinary keyword-search syntax, so they only ever bound the keyword half of a hybrid query. In the default mode the semantic half was free to return a document the keyword half had just excluded.

Exclusion failed a second time over, and this one is worse: the minus sign means nothing to an AI model. Left inside the query, -refurbished read as one more word of the request, so the semantic half moved results towards refurbished listings rather than away from them.

Before

With AI search on, an exclusion removed nothing — and often pushed the excluded results higher than they would have been without it.

Now

A prefixed term is applied as a filter over the whole result set and never reaches the AI model. Nothing containing it comes back, from either half.

02 The operators

OperatorWhat it doesExample
"word1 word2"Phrase — those words together, in that order"machine learning"
+wordRequired — every result must contain it+laptop 15 inch gaming
+"word1 word2"Required phrase+"13 inch"
-wordExcluded — drop any result containing itlaptop -refurbished
-"word1 word2"Excluded phrase-"open box"

They compose: +laptop +"13 inch" -refurbished returns only 13-inch laptops, and never a refurbished one.

03 Also in this release

  • Quoted phrases survive. They used to be stripped out of hybrid queries, so "machine learning" searched for the two words separately.
  • Filters no longer overwrite each other. A metadata filter used to drop both the operator filters and the Fresh Results Bias date clause.
  • Highlighting and spellcheck ignore the operators, so an excluded term is never highlighted in a result or offered as a suggestion.
  • A query that is nothing but operators still works. There is nothing to embed, so it runs as a keyword search — and still excludes.
  • Hyphenated words are safe. e-mail, covid-19 and 1+1 are searched for literally; + and - only count at the start of a word.

Nothing to configure, and keyword-only search is untouched — the operators always worked there and behave exactly as before. Update from drupal.org or with composer update drupal/opensolr_search.

View the full changelog