Hi there, I have an issue with the QueryScorer(query) method at the moment and I need some assistance. I was indexing my e-book "lucene in action" and based on this index-db I started to play around with some boolean queries like: (contents:+term contents:+query) As a result I'm expecting as a perfect match for the phrase "term query" four hits.
But when I run my sample to highlight this phrase in the context then I get a lot more results. It also finds all the matches for "term" and "query" independently. I think the problem is the QueryScorer() which softens the former exact boolean query. Then I was trying the following: private static Highlighter GetHits(Query query, Formatter formatter) { string filed = "contents" BooleanQuery termsQuery = new BooleanQuery(); WeightedTerm[] terms = QueryTermExtractor.GetTerms(query, true, field); foreach (WeightedTerm term in terms) { TermQuery termQuery = new TermQuery(new Term(field, term.GetTerm())); termsQuery.Add(termQuery, BooleanClause.Occur.MUST); } // create query scorer based on term queries (field specific) QueryScorer scorer = new QueryScorer(termsQuery); Highlighter highlighter = new Highlighter(formatter, scorer); highlighter.SetTextFragmenter(new SimpleFragmenter(20)); return highlighter; } to rewrite the query and set the term attribute from SHOULD to MUST But the result was the same. Do you have any example how I can use the QueryScorer() in exactly the same way as to mimic a BooleanSearch?? thanks in advance Christian --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org