[pylucene-dev] TopFieldDocs returned from indexSearcher are
wrong
Andi Vajda
vajda at osafoundation.org
Tue Sep 12 09:02:05 PDT 2006
On Tue, 12 Sep 2006, Yura Smolsky wrote:
> another issue... when I perform search on the field like this:
> Field("link", link, Field.Store.YES, Field.Index.UN_TOKENIZED)
>
> I got weird value of maxScore of TopFieldDocs.
>
> Here is program:
> from PyLucene import *
>
> dir = FSDirectory.getDirectory("../../index/index", False)
> searcher = IndexSearcher(dir)
> query = PrefixQuery(Term("link", "yahoo.com"))
> print query
> weight = query.weight(searcher)
> tfd = searcher.search(weight, None, 10, Sort())
> print 'TopFieldDocs.maxScore:', tfd.getMaxScore()
>
> output:
> link:yahoo.com*
> TopFieldDocs.maxScore: -1.#INF
>
That value should be -inf. Apparently, the maxScore is initialized to -inf
(negative infinity) in Lucene's FieldSortedHitQueue.java, line 77:
/** Stores the maximum score value encountered, needed for normalizing. */
protected float maxscore = Float.NEGATIVE_INFINITY;
> and of course I cannot build object of TopFieldDocs with such value. I
> am not sure where is error.. Please check.
In python, to create a float with negative infinity you say: float('-inf')
Andi..
More information about the pylucene-dev
mailing list