You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by ro...@earthlink.net on 2009/01/21 20:44:27 UTC
why would Explanation be *ALWAYS* null?
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-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: why would Explanation be *ALWAYS* null?
Posted by Chris Hostetter <ho...@fucit.org>.
: 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):
...
: // TODO SY - implement
: >>>>>>>>> return null;
: }
that's definitely not good ... but (unless i'm a *LOT* more tired then
i think) it's also not in the Lucene code base.
: 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);
I don't really understand that code ... it doesn't seem to be legal java.
is that last line suppose to be an assignment to a _parser variable from
a constructor to some class named XMLFragmentParser ?
where did you get XMLFragmentParser from? I'm seeing mentions here that
seem like they might be applicable, but i'm not fiding any code...
http://riao.free.fr/papers/15.pdf
: So -- what's the right thing to do?
I'd file a bug with whoever provided you the XMLFragmentParser and
MarkupContainsQuery classes.
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: why would Explanation be *ALWAYS* null?
Posted by Ian Lea <ia...@gmail.com>.
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, <ro...@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-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org