Lupuss
Lupuss

Reputation: 649

Multiple word search with Solr

I have a problem with Solr where I can't reconcile inexact search with multiple words.

Currently my Solr is configured thus: query=ctnt_val:*keyword* where ctnt_val is the field I'm searching and keyword the value I pass.

So if I type lon it will return all results with longer, London, ... which is what I want.

The problem is that if my query is several words long (e.g., Gotham City), it returns all results containing Gotham and all results containing City, instead of returning only all results containing Gotham City.

If I change the query as query=ctnt_val:"keyword" it works but then I lose the ability to do inexact searches (lon will no longer return London). If I do query=ctnt_val:*"keyword"* I get ALL results from my DB, which is clearly not what I want.

Any ideas?

Upvotes: 0

Views: 3795

Answers (1)

Jayendra
Jayendra

Reputation: 52769

The default search handler uses to have the OR as the default query operator.

You can check using q=ctnt_val:gotham\ city&q.op=AND which will set the query operator to AND and would make all the query terms as mandatory.

gotham\ city - \ is to escape the space from the query

Upvotes: 2

Related Questions