Srinivas Kallepalli
Srinivas Kallepalli

Reputation: 63

how to find a solr doc which has a complete match of given search term but in different search fields

I would like to find the documents which matches all the words of the given search term.

For example I search on below fields in solr.

  1. ProductName
  2. ProductDescription
  3. ProductSummary

When I search for "My First Product", I should get the document which has either complete term in any search field or if the match happened on more than one field in the document. i.e I should get first two documents in the results.

example data:

 {
   “ProductName”: “My”,
   "ProductDescription": “My First Product“,
   "ProductSummary": “Summary”
 },
 {
   “ProductName”: “My”,
   "ProductDescription": “First”,
   "ProductSummary": “Product”
 },
 {
   “ProductName”: “Product”,
   "ProductDescription": “First”,
   "ProductSummary": “Nothing”
 }
]  

How should I achieve that in solr? 

Upvotes: 0

Views: 132

Answers (1)

MatsLindh
MatsLindh

Reputation: 52802

Add a catch-all copy field (in the examples this might be configured under the name _text_).

You can then use mm=100% or q.op=AND to make sure that every term in your query gets matched when searching. mm requires either the dismax or the edismax (recommended) query parser (defType=edismax).

Upvotes: 1

Related Questions