support boost on block join query (nested)
This commit is contained in:
parent
90af54dad5
commit
b10094b109
|
@ -108,8 +108,6 @@ public class NestedQueryParser implements QueryParser {
|
|||
query = new DeletionAwareConstantScoreQuery(filter);
|
||||
}
|
||||
|
||||
query.setBoost(boost);
|
||||
|
||||
MapperService.SmartNameObjectMapper mapper = parseContext.smartObjectMapper(path);
|
||||
if (mapper == null) {
|
||||
throw new QueryParsingException(parseContext.index(), "[nested] failed to find nested object under path [" + path + "]");
|
||||
|
@ -141,6 +139,7 @@ public class NestedQueryParser implements QueryParser {
|
|||
parentFilterContext.set(currentParentFilterContext);
|
||||
|
||||
BlockJoinQuery joinQuery = new BlockJoinQuery(query, parentFilter, scoreMode);
|
||||
joinQuery.setBoost(boost);
|
||||
|
||||
if (scope != null) {
|
||||
SearchContext.current().addNestedQuery(scope, joinQuery);
|
||||
|
|
|
@ -144,12 +144,12 @@ public class BlockJoinQuery extends Query {
|
|||
|
||||
@Override
|
||||
public float sumOfSquaredWeights() throws IOException {
|
||||
return childWeight.sumOfSquaredWeights();
|
||||
return childWeight.sumOfSquaredWeights() * joinQuery.getBoost() * joinQuery.getBoost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void normalize(float norm) {
|
||||
childWeight.normalize(norm);
|
||||
childWeight.normalize(norm * joinQuery.getBoost());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -378,10 +378,12 @@ public class BlockJoinQuery extends Query {
|
|||
public Query rewrite(IndexReader reader) throws IOException {
|
||||
final Query childRewrite = childQuery.rewrite(reader);
|
||||
if (childRewrite != childQuery) {
|
||||
return new BlockJoinQuery(childQuery,
|
||||
Query rewritten = new BlockJoinQuery(childQuery,
|
||||
childRewrite,
|
||||
parentsFilter,
|
||||
scoreMode).setCollector(childCollector);
|
||||
rewritten.setBoost(getBoost());
|
||||
return rewritten;
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
|
@ -392,16 +394,6 @@ public class BlockJoinQuery extends Query {
|
|||
return "BlockJoinQuery (" + childQuery.toString() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoost(float boost) {
|
||||
throw new UnsupportedOperationException("this query cannot support boosting; please use childQuery.setBoost instead");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoost() {
|
||||
throw new UnsupportedOperationException("this query cannot support boosting; please use childQuery.getBoost instead");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object _other) {
|
||||
if (_other instanceof BlockJoinQuery) {
|
||||
|
|
Loading…
Reference in New Issue