lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From KEGan <>
Subject Re: Number Proximity Query
Date Wed, 04 Oct 2006 18:57:57 GMT
Chris, thanks again for your reply. Really appreciate your help.

Another quick question on the score. If my custom Query is returning a score
that can be any value, and this custom Query is being used together with
other standard Query in a BooleanQuery. How do I ensure the value return by
the custome Query doesnt 'overshadow' the values return by other standard

Example, if the custom Query return values in range of 0-1,000, whereas
other standard Query return values in range of 0-5. Then the score by the
custom Query virtually dominates the overall document score.

I am not sure if I am asking the correct question :) It's 3am now. I will
write more tomorrow. Good night :)


On 10/5/06, Chris Hostetter <> wrote:
> : (1) Should values returned by DocValues (return from ValueSource) must
> : always betwen 1.0 and 0.0 ? How is this value affect the overall
> document
> : scores, assuming there are others Query clauses as well that is perform
> on
> : the document (on other fields).
> The "values" returned by the various methods in DocValues can be anything
> you want, as long as they conform to hte primitive datatype in the method
> sig -- ideally whatever float floatVal returns should be roughly
> equivilent to whever double you return from doubleVal so that your
> ValueSource appears to behave the same way regardless of whatever other
> ValueSources you may compose it in.
> How the values affect the over all Document score really depends on how
> big the values you return are, and how you compose your FunctionQuery with
> the other parts of your query (presumably in a BooleanQuery)
> Take a look at LinearFloatFunction and the DocValues it produces.  it's a
> good example of what a "function" you want to be able to compose in a
> function query should do.
> If i remember your problem statement correctly, all you really need is an
> AbsoluteValueFunction that you could compose with some linear functions
> ala:  linear(abs(linear(field(x), -1, N), -1, M)))
> ...where N is the magic number you want your doc vals to be close to, M is
> the biggest value you ever want your FunctionQuery to score a document
> with, and field(x) is where you put a FieldCacheSource on the field you
> care about.
> Your AbsoluteValueFunction would look a lot like LinearFloatFunction, with
> out the slope or intercept and a getValues method that looked something
> like...
> public DocValues getValues(IndexReader reader) throws IOException {
>    final DocValues vals =  source.getValues(reader);
>    return new DocValues() {
>      public float floatVal(int doc) {
>        return Math.abs(vals.floatVal(doc))
>      }
>      ...
> : (2) The documentation on the following functions is extremely lacking
> (no
> : matter where I looked). Any expert here can help out ?
> :
> : -- Weight.getValue() : what values should be returned for
> : NumberProximityQuery?
> : -- Weight.sumOfSquareWeights() : no idea what is this for???
> : -- Weight.normalize() : still no idea
> : -- Scorer.score() : should this value always between 1.0 and 0.0 ?
> I honestly don't remember off the top of me head what those methods are
> for our how they come into play -- the scoring.html doc that's in progress
> should help clear up some of that.  As i recall, the last time i needed to
> understand what those methods did, i looked at some of the primitive query
> types (like TermQuery and BooleanQuery) to see what they did.
> The one thing I can tell you with certainty is that there is nothing
> magical about scores between 0.0 and 1.0 -- the notion that Lucene Scores
> are between 0 and 1 is a myth perpetuated by the Hits interface which does
> a mock-normalization of the scores if the highest is greater then 1.
> When you get down into the bowels of scoring, the scores can be any float
> -- even negative numbers are legal scores.
> -Hoss
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message