Have you tried it without the rewrite, marked as "expert" in the javadocs?
I'm not a lucene expert but I am an experienced user and in several years of usage I don't think I've ever had cause to call Query.rewrite(). -- Ian. On Wed, Jan 21, 2009 at 7:44 PM, <rolaren...@earthlink.net> wrote: > R2.4 > > There is much about Lucene that I do not understand, so it may be that there > is some simple or obvious mistake I am making. I build an index, get hits > (documents) back from it, with various non-zero scores. Now I call this code: > > Explanation expl = _searcher.explain(rewrite, docIndex); // always > null! > > And the return value is *ALWAYS* null. The javadocs on explain() do not even > mention that possibility. When I debug through the call, I find the > "explanation" in this code inside class MarkupContainsQuery (which is the > code that gets called): > > /** > * @see Weight#explain(IndexReader, int) > */ > public Explanation explain(IndexReader reader, int doc) > throws IOException { > if (reader == null) { > throw new IOException("Empty reader in explain > method"); > } > // TODO SY - implement >>>>>>>>>> return null; > } > > This seems, um, bad, esp. as I did nothing to *decide* the type of my query, > but merely created it from the user-entered string like this: > > Query query = _parser.parse(queryString); > Query rewrite = query.rewrite(_reader); > > And the field _parser was created like this: > > Analyzer analyzer = new StandardAnalyzer(); > QueryParser parser = new QueryParser("contents", analyzer); > _parser XMLFragmentParser(parser); > > So -- what's the right thing to do? > > thanks, > Paul > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org