lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: Question about CustomScoreQuery
Date Mon, 20 Feb 2012 17:38:47 GMT
I can't explain this.  Can you get at an oal.search.Explanation?  You
could write your own CustomScoreProvider - that might help you to
double check what is being passed to it, and/or allow you to provide
your own calculation.


--
Ian.


On Thu, Feb 16, 2012 at 8:32 PM, Dominika Puzio
<dominika.puzio@gmail.com> wrote:
> Hello,
> I'm trying to understand the behavior of CustomScoreQuery. It seemed to me,
> that default
> CustomScoreQuery(Query subQuery, ValueSourceQuery valSrcQuery)
> should return a score that is a product of subQuery score
> and valSrcQuery score. So I wrote a simple test case given below:
>
>      @Test
>      public void createAndQueryIndex() throws CorruptIndexException,
> LockObtainFailedException, IOException {
>
>              RAMDirectory dir = new RAMDirectory();
>              IndexWriter writer = new IndexWriter(dir,
>                              new IndexWriterConfig(Version.LUCENE_35,
> new StandardAnalyzer(
>                                              Version.LUCENE_35)));
>
>              Document doc = new Document();
>              doc.add(new Field("name", "name", Store.YES, Index.NOT_ANALYZED));
>              doc.add(new Field("ratio", "0.5", Store.YES, Index.NOT_ANALYZED));
>
>              writer.addDocument(doc);
>              writer.close();
>
>
>              IndexSearcher searcher = new IndexSearcher(IndexReader.open(dir));
>
>              Query matchAllDocs = new MatchAllDocsQuery();
>              float score1 = searcher.search(matchAllDocs,
> 1).scoreDocs[0].score;
>              Assert.assertEquals(1.0f, score1, 0);
>
>              ValueSourceQuery fieldScoreQuery = new FieldScoreQuery("ratio",
> FieldScoreQuery.Type.FLOAT);
>              float score2 = searcher.search(fieldScoreQuery,
> 1).scoreDocs[0].score;
>              Assert.assertEquals(0.5f, score2, 0);
>
>
>              CustomScoreQuery csq = new CustomScoreQuery(matchAllDocs,
> fieldScoreQuery);
>              float score3 = searcher.search(csq, 1).scoreDocs[0].score;
>              Assert.assertEquals(score1*score2, score3, 0);
>
>              searcher.close();
>      }
>
> But this test fails in third assertion - score3 is 0.249. Can someone
> explain why? How the score3 is computed in this case?
>
> --
> Regards
> Dominika Puzio
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message