On Sun, Oct 11, 2009 at 9:10 AM, Jake Mannix <[email protected]> wrote:
> What do you mean "not something I can plug in on top of my original query"?
>
> Do you mean that you can't do it like the more complex example in the class
> you posted earlier in the thread, where you take a linear combination of
> the
> Map<String, Float> -based score, and the regular text score?
>
Yes exactly.
>
> Another option is to just use the CustomScoreQuery like your other
> attempt is:
>
> --------
> public class QueryTermBoostingQuery extends CustomScoreQuery {
> private float bias;
>
> public QueryTermBoostingQuery (Query q, ValueSourceQuery[] vQueries, float
> bias) {
> super(q, vQueries);
> this.bias = bias;
> }
>
> @Override
> public float customScore(int doc, float subQueryScore, float[]
> valSrcScores) {
> float termWeightedScore = 0;
> for(float valSrcScore : valSrcScores) termWeightedScore +=
> valSrcScore;
> return bias * subQueryScore + (1 - bias) * termWeightedScore;
> }
> }
>
> And then to use it, you build up some FloatFieldSource instances like
> before:
>
> FloatFieldSource m1 = // defined like I did in my previous message
> FloatFieldSource m2 = //...
> FloatFieldSource m3 = //...
>
> ValueSourceQuery vsq1 = new ValueSourceQuery(m1);
> vsq1.setBoost(model1Weight);
>
> // vsq2 and vsq3 also
>
> ValueSourceQuery[] vsq = { vsq1, vsq2, vsq3 };
>
> Query textQuery = QueryParser.parse("company:Microsoft");
>
> Query q = new QueryTermBoostingQuery(textQuery, vsq, bias);
> -------
>
> Does this work for you?
>
Yes I think this should work! Thanks for taking the time to clearly write up
a solution. Will report back after testing it out.
best,
Scott