lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jake Mannix <>
Subject Re: Question about how to speed up custom scoring
Date Fri, 09 Oct 2009 22:33:44 GMT
On Fri, Oct 9, 2009 at 3:07 PM, scott w <> wrote:

> Example Document:
> model_1_score = 0.9
> model_2_score = 0.3
> model_3_score = 0.7
> I want to be able to pass in the following map at query time:
> {model_1_score=0.4, model_2_score=0.7} and have that map get used as input
> to a custom score function that would look like: 0.9*0.4 + 0.3*0.7, so that
> it is summing over the specified fields and multipling the indexed weight
> by
> the query time weight.

Ok, now I think I get it.  You do have some index-time floats, and

You should be able to do a normal BooleanQuery with three OR'ed together
ValueSourceQueries boosted by input weights, it seems, as that is the way
they work - they take the values in different fields and use them as the
and the normal boosting technique will use query time weigting.

To get good performance with a ValueSourceQuery, I'd suggest using a
FieldCacheSource for speedier processing:

  String field = "model_1_score";
  float runTimeBoost = 0.5;

  ValueSource model1Source = new FloatFieldSource(field,
    new FieldCache.FloatParser() {
      public float parseFloat(String s) { return Float.parseFloat(s); }

  Query model1Q = new ValueSourceQuery(model1Source);


// do this for model2 and model3 as well...

  BooleanQuery bq = new BooleanQuery();
  bq.add(model1Q, Occur.SHOULD);
  bq.add(model2Q, Occur.SHOULD);
  bq.add(model3Q, Occur.SHOULD);

  I haven't tried this code, but it seems like this is what you are trying
to do...


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