0

I'm having a field called "QUERY_TERMS" which consists of words separated by a space.

Example: "QUERY_TERMS": "chet swaroop"

This record/document should be returned as a result only when the query contains both the terms included in the list say "chet" and "swaroop"

Example: Instances when the record/document is returned in Solr, i.) "chet swaroop" ii.) "swaroop chet: iii.) "chet blah blah swaroop" iv.) "swaroop blah blah chet"

Instances when the record/document should not be returned in Solr, i.) "chet" ii.)"swaroop" iii.)" chet blah blah" iv.) "blha blah swaroop"

Could anyone suggest the query to match the above requirements.

Chethan Swaroop
  • 160
  • 2
  • 12

3 Answers3

1

If by both, you mean all terms provided, then you should look into mm=100% available with disMax and eDisMax.

Alexandre Rafalovitch
  • 9,709
  • 1
  • 24
  • 27
  • setting mm=100% wont work for the above specified use cases. As cases like iii.) "chet blah blah swaroop" iv.) "swaroop blah blah chet" wont return any results. And will return documents with queries like i.) "chet" ii.)"swaroop" were user dont want any docs to be returned – shubham Jan 28 '17 at 06:28
  • How are you making the query? As a phrase in quotes? Or as a non-phrase query against specific field (set with df). What happens if you use +field:chet +field:swaroop which is equivalent to mm=100% for this case? Try checking with debug enabled. – Alexandre Rafalovitch Jan 28 '17 at 18:25
  • @shubham.. you are right.. it did not work for those cases. – Chethan Swaroop Jan 30 '17 at 18:33
  • @AlexandreRafalovitch I've not been able to make a query for this, I can configure my Solr query in anyway possible to get the desired result. – Chethan Swaroop Jan 30 '17 at 18:35
0

have a look at the below link :- http://www.solrtutorial.com/solr-query-syntax.html

If the distance between the two words are somewhat fixed and known then Proximity Mathching may help .

Piyush_Rana
  • 305
  • 3
  • 15
0

(chet && swaroop) will return record/document as a result only when the query contains both the terms included in the list say "chet" and "swaroop"