Skip to content

Commit aea3034

Browse files
committed
spotting where type check should happen
1 parent d1c5efe commit aea3034

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/queries/TextExpansionQueryBuilder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.io.IOException;
3939
import java.util.List;
4040
import java.util.Objects;
41+
import java.util.Set;
4142

4243
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
4344
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
@@ -59,6 +60,8 @@ public class TextExpansionQueryBuilder extends AbstractQueryBuilder<TextExpansio
5960
private SetOnce<TextExpansionResults> weightedTokensSupplier;
6061
private final TokenPruningConfig tokenPruningConfig;
6162

63+
private static final Set<String> ALLOWED_FIELD_TYPES = Set.of("sparse_vector", "rank_features");
64+
6265
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ParseField.class);
6366
public static final String TEXT_EXPANSION_DEPRECATION_MESSAGE = NAME + " is deprecated. Use sparse_vector instead.";
6467

@@ -158,6 +161,8 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) {
158161
return weightedTokensToQuery(fieldName, weightedTokensSupplier.get());
159162
}
160163

164+
// Do field type check if query won't be rewritten as a WeightedTokensQuery
165+
161166
CoordinatedInferenceAction.Request inferRequest = CoordinatedInferenceAction.Request.forTextInput(
162167
modelId,
163168
List.of(modelText),

0 commit comments

Comments
 (0)