开发者

Solr: Search in multiple fields BUT STOP if documents match was found

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 wa开发者_JAVA百科nt 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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜