FunctionQuery functionQuery = new FunctionQuery(valueSource);
IndexReader r = DirectoryReader.open(dir);
IndexSearcher s = newSearcher(r);
// regular (boolean) query.
BooleanQuery q1 = new BooleanQuery();
q1.add(new TermQuery(new Term(TEXT_FIELD, "first")), BooleanClause.Occur.SHOULD);
q1.add(new TermQuery(new Term(TEXT_FIELD, "aid")), BooleanClause.Occur.SHOULD);
q1.add(new TermQuery(new Term(TEXT_FIELD, "text")), BooleanClause.Occur.SHOULD);
log(q1);
// custom query, that should score the same as q1.
BooleanQuery q2CustomNeutral = new BooleanQuery(true);
Query q2CustomNeutralInner = new CustomScoreQuery(q1);
q2CustomNeutral.add(q2CustomNeutralInner, BooleanClause.Occur.SHOULD);
// a little tricky: we split the boost across an outer BQ and CustomScoreQuery
// this ensures boosting is correct across all these functions (see LUCENE-4935)
q2CustomNeutral.setBoost((float)Math.sqrt(dboost));
q2CustomNeutralInner.setBoost((float)Math.sqrt(dboost));
log(q2CustomNeutral);
// custom query, that should (by default) multiply the scores of q1 by that of the field
CustomScoreQuery q3CustomMul = new CustomScoreQuery(q1, functionQuery);