diff --git a/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/builders/AqpAdsabsSubQueryProvider.java b/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/builders/AqpAdsabsSubQueryProvider.java index dd97515fd..f558bae18 100644 --- a/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/builders/AqpAdsabsSubQueryProvider.java +++ b/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/builders/AqpAdsabsSubQueryProvider.java @@ -601,8 +601,9 @@ public Query parse(FunctionQParser fp) throws SyntaxError { SortSpec sortSpec = SortSpecParsing.parseSortSpec(sortOrRank, fp.getReq()); + Query q; if (sortSpec.getSort() == null) { - return new SecondOrderQuery(innerQuery, + q = new SecondOrderQuery(innerQuery, new SecondOrderCollectorTopN(topN)); } else { @@ -616,9 +617,11 @@ public Query parse(FunctionQParser fp) throws SyntaxError { throw new SyntaxError("I am sorry, you can't use " + sortOrRank + " for topn() sorting. Reason: " + e.getMessage()); } - return new SecondOrderQuery(innerQuery, + q = new SecondOrderQuery(innerQuery, new SecondOrderCollectorTopN(sortOrRank.toString(), topN, sortOrder)); } + + return AqpScoringQueryNodeBuilder.wrapQuery(q, "cite_read_boost", 0.5f); } }); diff --git a/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/builders/AqpScoringQueryNodeBuilder.java b/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/builders/AqpScoringQueryNodeBuilder.java index 8bdd1c8c6..a1e37f7a5 100644 --- a/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/builders/AqpScoringQueryNodeBuilder.java +++ b/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/builders/AqpScoringQueryNodeBuilder.java @@ -23,24 +23,28 @@ * score = lucene_score * ( classic_factor + modifier ) */ public class AqpScoringQueryNodeBuilder implements StandardQueryBuilder { - + public Query build(QueryNode queryNode) throws QueryNodeException { - - AqpAdsabsScoringQueryNode q = (AqpAdsabsScoringQueryNode) queryNode; - - Query query = (Query) queryNode.getChildren().get(0).getTag( - QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID); - - ValueSource vs = new SumFloatFunction(new ValueSource[] { - new FloatFieldSource(q.getSource()), // classic score - new ConstValueSource(q.getModifier()) // modifier - }); - - - FunctionQuery functionQuery = new FunctionQuery(vs); - return new CustomScoreQuery(query, functionQuery); - - } + + AqpAdsabsScoringQueryNode q = (AqpAdsabsScoringQueryNode) queryNode; + + Query query = (Query) queryNode.getChildren().get(0).getTag( + QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID); + + return wrapQuery(query, q.getSource(), q.getModifier()); + + } + + public static Query wrapQuery(Query q, String source, float modifier) { + ValueSource vs = new SumFloatFunction(new ValueSource[] { + new FloatFieldSource(source), // classic score + new ConstValueSource(modifier) // modifier of how much lucene score to use + }); + + + FunctionQuery functionQuery = new FunctionQuery(vs); + return new CustomScoreQuery(q, functionQuery); + } }