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 Phanindra R <ph...@gmail.com> on 2012/07/28 00:56:52 UTC

Weird scenario: Score 'explain' description showing different doc id

Hi,
      This is the first time I am encountering this kind of scenario. Lack
of knowledge might be the reason for my surprise.

- I am using myIndexWriter.explain(Query q, int docId).

- For the same query, the explanation for most of the docs is exactly what
it's supposed to be. However, for some docId, the explanation is showing a
different doc id. That doc id doesn't even have the passed in query term.
The following is the output.

Explaining: Doc id: *73714*, Query: MY_FIELD:bike

60.828213 = (MATCH) fieldWeight(MY_FIELD:bike in *22973*), product of:
  1.7320508 = tf(termFreq(MY_FIELD:bike)=3)
  70.23837 = idf(docFreq=272, maxDocs=438145)
  0.5 = fieldNorm(field=MY_FIELD, doc=*22973*)

You may notice that the underlined doc ids are different from each other.
The "same" code is working perfectly fine for other document ids.

Here is the code snippet, just in case.

    private void explainQuery(Query q, int doc) throws IOException {
        System.out.println("Explaining: " + doc + ", Query: " + q );
        Explanation exp = is.explain(q, doc);
        System.out.println(exp);
    }

I am not able to figure out the reason behind it.

Thanks,
Phani

Re: Weird scenario: Score 'explain' description showing different doc id

Posted by Phanindra R <ph...@gmail.com>.
I've found the answer. I am using the CustomScoreQuery and the doc id
inconsistency is because of the segment based IndexReader concept.

On Fri, Jul 27, 2012 at 3:56 PM, Phanindra R <ph...@gmail.com> wrote:

>
> Hi,
>       This is the first time I am encountering this kind of scenario. Lack
> of knowledge might be the reason for my surprise.
>
> - I am using myIndexWriter.explain(Query q, int docId).
>
> - For the same query, the explanation for most of the docs is exactly what
> it's supposed to be. However, for some docId, the explanation is showing a
> different doc id. That doc id doesn't even have the passed in query term.
> The following is the output.
>
> Explaining: Doc id: *73714*, Query: MY_FIELD:bike
>
> 60.828213 = (MATCH) fieldWeight(MY_FIELD:bike in *22973*), product of:
>   1.7320508 = tf(termFreq(MY_FIELD:bike)=3)
>   70.23837 = idf(docFreq=272, maxDocs=438145)
>   0.5 = fieldNorm(field=MY_FIELD, doc=*22973*)
>
> You may notice that the underlined doc ids are different from each other.
> The "same" code is working perfectly fine for other document ids.
>
> Here is the code snippet, just in case.
>
>     private void explainQuery(Query q, int doc) throws IOException {
>         System.out.println("Explaining: " + doc + ", Query: " + q );
>         Explanation exp = is.explain(q, doc);
>         System.out.println(exp);
>     }
>
> I am not able to figure out the reason behind it.
>
> Thanks,
> Phani
>