Skip to content

Commit 370931d

Browse files
fixing for match subquery
1 parent 9338cd5 commit 370931d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticMatchQueryRewriteInterceptor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ protected QueryBuilder buildCombinedInferenceAndNonInferenceQuery(
5454
assert (queryBuilder instanceof MatchQueryBuilder);
5555
MatchQueryBuilder matchQueryBuilder = (MatchQueryBuilder) queryBuilder;
5656
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
57-
SemanticQueryBuilder semanticQueryBuilder = createSemanticSubQuery(
57+
QueryBuilder semanticQueryBuilder = createSemanticSubQuery(
5858
indexInformation.getInferenceIndices(),
5959
matchQueryBuilder.fieldName(),
60-
(String) matchQueryBuilder.value()
60+
(String) matchQueryBuilder.value(),
61+
matchQueryBuilder.boost(),
62+
matchQueryBuilder.queryName()
6163
);
62-
semanticQueryBuilder.boost(matchQueryBuilder.boost());
63-
semanticQueryBuilder.queryName(matchQueryBuilder.queryName());
6464
boolQueryBuilder.should(semanticQueryBuilder);
6565
boolQueryBuilder.should(createSubQueryForIndices(indexInformation.nonInferenceIndices(), matchQueryBuilder));
6666
return boolQueryBuilder;

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticQueryRewriteInterceptor.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,13 @@ protected QueryBuilder createSubQueryForIndices(Collection<String> indices, Quer
114114
return boolQueryBuilder;
115115
}
116116

117-
protected QueryBuilder createSemanticSubQuery(Collection<String> indices, String fieldName, String value) {
117+
protected QueryBuilder createSemanticSubQuery(Collection<String> indices, String fieldName, String value, Float boost, String queryName) {
118+
SemanticQueryBuilder semanticQueryBuilder = new SemanticQueryBuilder(fieldName, value, true);
119+
semanticQueryBuilder.boost(boost);
120+
semanticQueryBuilder.queryName(queryName);
121+
118122
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
119-
boolQueryBuilder.must(new SemanticQueryBuilder(fieldName, value, true));
123+
boolQueryBuilder.must(semanticQueryBuilder);
120124
boolQueryBuilder.filter(new TermsQueryBuilder(IndexFieldMapper.NAME, indices));
121125
return boolQueryBuilder;
122126
}

0 commit comments

Comments
 (0)