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 = new DeletionAwareConstantScoreQuery(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
query.setBoost(boost);
|
|
||||||
|
|
||||||
MapperService.SmartNameObjectMapper mapper = parseContext.smartObjectMapper(path);
|
MapperService.SmartNameObjectMapper mapper = parseContext.smartObjectMapper(path);
|
||||||
if (mapper == null) {
|
if (mapper == null) {
|
||||||
throw new QueryParsingException(parseContext.index(), "[nested] failed to find nested object under path [" + path + "]");
|
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);
|
parentFilterContext.set(currentParentFilterContext);
|
||||||
|
|
||||||
BlockJoinQuery joinQuery = new BlockJoinQuery(query, parentFilter, scoreMode);
|
BlockJoinQuery joinQuery = new BlockJoinQuery(query, parentFilter, scoreMode);
|
||||||
|
joinQuery.setBoost(boost);
|
||||||
|
|
||||||
if (scope != null) {
|
if (scope != null) {
|
||||||
SearchContext.current().addNestedQuery(scope, joinQuery);
|
SearchContext.current().addNestedQuery(scope, joinQuery);
|
||||||
|
|
|
@ -144,12 +144,12 @@ public class BlockJoinQuery extends Query {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float sumOfSquaredWeights() throws IOException {
|
public float sumOfSquaredWeights() throws IOException {
|
||||||
return childWeight.sumOfSquaredWeights();
|
return childWeight.sumOfSquaredWeights() * joinQuery.getBoost() * joinQuery.getBoost();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void normalize(float norm) {
|
public void normalize(float norm) {
|
||||||
childWeight.normalize(norm);
|
childWeight.normalize(norm * joinQuery.getBoost());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -378,10 +378,12 @@ public class BlockJoinQuery extends Query {
|
||||||
public Query rewrite(IndexReader reader) throws IOException {
|
public Query rewrite(IndexReader reader) throws IOException {
|
||||||
final Query childRewrite = childQuery.rewrite(reader);
|
final Query childRewrite = childQuery.rewrite(reader);
|
||||||
if (childRewrite != childQuery) {
|
if (childRewrite != childQuery) {
|
||||||
return new BlockJoinQuery(childQuery,
|
Query rewritten = new BlockJoinQuery(childQuery,
|
||||||
childRewrite,
|
childRewrite,
|
||||||
parentsFilter,
|
parentsFilter,
|
||||||
scoreMode).setCollector(childCollector);
|
scoreMode).setCollector(childCollector);
|
||||||
|
rewritten.setBoost(getBoost());
|
||||||
|
return rewritten;
|
||||||
} else {
|
} else {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -392,16 +394,6 @@ public class BlockJoinQuery extends Query {
|
||||||
return "BlockJoinQuery (" + childQuery.toString() + ")";
|
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
|
@Override
|
||||||
public boolean equals(Object _other) {
|
public boolean equals(Object _other) {
|
||||||
if (_other instanceof BlockJoinQuery) {
|
if (_other instanceof BlockJoinQuery) {
|
||||||
|
|
Loading…
Reference in New Issue