Hi,
Lucene is working exactly like you want. Just use the given Search query, which parses by default to a SHOULD query (this is similar to OR, but not identical, see: http://searchhub.org/2011/12/28/why-not-and-or-and-not/). There is no need to bring “AND” (“MUST” in Lucene speak) into the query, as AND+OR at the same time cannot work. Your example will automatically work correct, because the used TF-IDF (http://en.wikipedia.org/wiki/Tf%E2%80%93idf) ranking algorithm will give the documents with more hits a higher score than those with only one hit. But keep in mind, as TF-IDF not only takes the number of hits into account, but also inverse document frequency and possible field boosts, so the sort order can be different (depending on your document contents). E.g. a very short document with only one of the terms *may* get a higher score than a veeeeeeeeeeeery long document with multiple hits (because a hit on term in a short document is more significant than a hit on the same term in a very long document). Uwe ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de <http://www.thetaphi.de/> eMail: [email protected] From: Raja Kulasekaran [mailto:[email protected]] Sent: Thursday, February 21, 2013 9:07 AM To: [email protected] Subject: Search Strategy Hi, I would like to have a AND operation as well as OR operation in single query . Can you suggest me how do I do it ? For example, If the query Text is "Laud the People" then , I want the results of : "Laud the People" "Laud" "the" "People" whereas "Laud the People" should get higher precedence. Any suggestion on this . Even Google takes "AND" as well "OR" differently . Raja
