1
votes

I want to search in multiple fields in Solr. (In know the concept of the copy-fields and I know the (e)dismax search handler.)

So I have an orderd list of fields, I want the terms to be searched against. 1.) SKU 2.) Name 3.) Description 4.) Summary and so on.

Now, when the query matches a term, let's say in the SKU field, I want this match and no further searches in the proceeding fields.

Only, if there are NO matches at all in the first field (SKU field), the second field (in this case "name") should be used and so on.

Is this possible with Solr? Do I have to implement my own Lucene Search Handler for this?

Any advice is welcome!

Thank you, Bernhard

2

2 Answers

2
votes

I think your case requires executing 4 different searches. If you implement you very own SearchHandler you could avoid penalty of search result accumulation in 4 different request. Which means, you would send one query, and custom SearchHandler would execute 4 searches and prepare one result set.

0
votes

If my guess is right you want to rank the results based on the order of the fields. If so then you can just use standard query like

q=sku:(query)^4 OR name:(query)^3 OR description:(query)^2 OR summary:(query)

this will rank the results by the order of the fields.

Hope is helps.