Hi All, I need to create a boolean query with MUST clause as well as SHOULD Clause. The result I get is the one which has MUST Clause but there are no SHOULD Clause present. I need something like the following +term:abc +loc:nyc and one of the ngrams for spell check like spell:co, spell:cor and so on
Currently if include them as one BooleanQuery I get the doc maching the must clause on top but does not have any of the spell field used. So I tried to used setMinimumNumberShouldMatch(1), which causes no documents to match. I tried the following approaches Approach : 1 a. All Must Terms in one BooleanQuery b. All SpellTerms as Should in Second BooleanQuery c. FinalQuery as MustBooleanQuery and SpellBooleanQuery ( both added as Must) : output no results found Approach : 2 a. All Must Terms in One BooleanQuery b. All SpellTerms added as Should Clauses to finalQuery c. Adding MustBooleanQuery to finalQuery : Top record match found only has Must part and no should clauses Approach :3 Same as 2 but with setMinimumNumberShouldMatch(1), so that atleast one spellTerms is matched : Output is no result found Approach :4 a. Add All Must terms into finalquery as Must Clause b.All SpellTerms added as Should Clauses to finalQuery c.Result: Top record match found only has Must part and no should clauses Approach :5 Same as 4 but with setMinimumNumberShouldMatch(1) c.Result: No Result Found I am calling TopDocs = searcher.search(finalQuery,MAX_HITS); in all the above cases and using Lucene 3.0.2 Can someone help me in getting this query right to get atleast one spellterm to be matched with the document. --Thanks and Regards Vaijanath N. Rao