Skip to content

Commit e788bfb

Browse files
Remove previous implementation
1 parent 12c1547 commit e788bfb

File tree

3 files changed

+0
-122
lines changed

3 files changed

+0
-122
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
import org.elasticsearch.xpack.inference.mapper.SemanticInferenceMetadataFieldsMapper;
9494
import org.elasticsearch.xpack.inference.mapper.SemanticTextFieldMapper;
9595
import org.elasticsearch.xpack.inference.queries.SemanticKnnVectorQueryRewriteInterceptor;
96-
import org.elasticsearch.xpack.inference.queries.SemanticMatchAllQueryRewriteInterceptor;
9796
import org.elasticsearch.xpack.inference.queries.SemanticMatchQueryRewriteInterceptor;
9897
import org.elasticsearch.xpack.inference.queries.SemanticQueryBuilder;
9998
import org.elasticsearch.xpack.inference.queries.SemanticSparseVectorQueryRewriteInterceptor;
@@ -548,7 +547,6 @@ public List<QueryRewriteInterceptor> getQueryRewriteInterceptors() {
548547
return List.of(
549548
new SemanticKnnVectorQueryRewriteInterceptor(),
550549
new SemanticMatchQueryRewriteInterceptor(),
551-
new SemanticMatchAllQueryRewriteInterceptor(),
552550
new SemanticSparseVectorQueryRewriteInterceptor()
553551
);
554552
}

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

Lines changed: 0 additions & 59 deletions
This file was deleted.

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

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.elasticsearch.cluster.metadata.InferenceFieldMetadata;
1313
import org.elasticsearch.index.mapper.IndexFieldMapper;
1414
import org.elasticsearch.index.query.BoolQueryBuilder;
15-
import org.elasticsearch.index.query.MatchAllQueryBuilder;
1615
import org.elasticsearch.index.query.QueryBuilder;
1716
import org.elasticsearch.index.query.QueryRewriteContext;
1817
import org.elasticsearch.index.query.TermsQueryBuilder;
@@ -23,7 +22,6 @@
2322
import java.util.HashMap;
2423
import java.util.List;
2524
import java.util.Map;
26-
import java.util.Set;
2725
import java.util.stream.Collectors;
2826

2927
/**
@@ -43,11 +41,6 @@ public QueryBuilder interceptAndRewrite(QueryRewriteContext context, QueryBuilde
4341
return queryBuilder;
4442
}
4543

46-
if (fieldName == null && getQueryName().equals(MatchAllQueryBuilder.NAME)) {
47-
return queryBuilder;
48-
// return handleMatchAllQuery(queryBuilder, resolvedIndices);
49-
}
50-
5144
InferenceIndexInformationForField indexInformation = resolveIndicesForField(fieldName, resolvedIndices);
5245
if (indexInformation.getInferenceIndices().isEmpty()) {
5346
// No inference fields were identified, so return the original query.
@@ -64,30 +57,6 @@ public QueryBuilder interceptAndRewrite(QueryRewriteContext context, QueryBuilde
6457
}
6558
}
6659

67-
private QueryBuilder handleMatchAllQuery(QueryBuilder queryBuilder, ResolvedIndices resolvedIndices) {
68-
if (getInferenceFieldsFromResolveIndices(resolvedIndices).isEmpty()) {
69-
// No inference fields were identified, so return the original query.
70-
return queryBuilder;
71-
}
72-
73-
List<String> fieldList = new ArrayList<>(getFieldsFromResolveIndices(resolvedIndices));
74-
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
75-
for (String field : fieldList) {
76-
InferenceIndexInformationForField indexInformation = resolveIndicesForField(field, resolvedIndices);
77-
if (indexInformation.nonInferenceIndices().isEmpty() == false) {
78-
// Combined case where the field name requested by this query contains both
79-
// semantic_text and non-inference fields, so we have to combine queries per index
80-
// containing each field type.
81-
boolQueryBuilder.should(buildCombinedInferenceAndNonInferenceQuery(queryBuilder, indexInformation));
82-
} else {
83-
// The only fields we've identified are inference fields (e.g. semantic_text),
84-
// so rewrite this semantic_text field into a semantic query
85-
boolQueryBuilder.should(buildInferenceQuery(queryBuilder, indexInformation));
86-
}
87-
}
88-
return boolQueryBuilder.should().isEmpty() ? queryBuilder : boolQueryBuilder;
89-
}
90-
9160
/**
9261
* @param queryBuilder {@link QueryBuilder}
9362
* @return The singular field name requested by the provided query builder.
@@ -121,36 +90,6 @@ protected abstract QueryBuilder buildCombinedInferenceAndNonInferenceQuery(
12190
InferenceIndexInformationForField indexInformation
12291
);
12392

124-
private List<String> getFieldsFromResolveIndices(ResolvedIndices resolvedIndices) {
125-
Collection<IndexMetadata> indexMetadataCollection = resolvedIndices.getConcreteLocalIndicesMetadata().values();
126-
List<String> fields = new ArrayList<>();
127-
for (IndexMetadata indexMetadata : indexMetadataCollection) {
128-
if (indexMetadata.mapping() == null || indexMetadata.mapping().sourceAsMap() == null) {
129-
// No mapping, so no fields.
130-
continue;
131-
}
132-
Collection<Object> mappingSource = indexMetadata.mapping().getSourceAsMap().values();
133-
@SuppressWarnings("unchecked")
134-
Set<String> fieldNames = mappingSource.stream()
135-
.filter(obj -> obj instanceof Map<?, ?>)
136-
.map(obj -> (Map<String, Object>) obj)
137-
.flatMap(map -> map.keySet().stream())
138-
.collect(Collectors.toSet());
139-
fields.addAll(fieldNames);
140-
}
141-
return fields;
142-
}
143-
144-
private List<InferenceFieldMetadata> getInferenceFieldsFromResolveIndices(ResolvedIndices resolvedIndices) {
145-
Collection<IndexMetadata> indexMetadataCollection = resolvedIndices.getConcreteLocalIndicesMetadata().values();
146-
List<InferenceFieldMetadata> inferenceIndicesMetadata = new ArrayList<>();
147-
for (IndexMetadata indexMetadata : indexMetadataCollection) {
148-
inferenceIndicesMetadata.addAll(indexMetadata.getInferenceFields().values());
149-
}
150-
151-
return inferenceIndicesMetadata;
152-
}
153-
15493
private InferenceIndexInformationForField resolveIndicesForField(String fieldName, ResolvedIndices resolvedIndices) {
15594
Collection<IndexMetadata> indexMetadataCollection = resolvedIndices.getConcreteLocalIndicesMetadata().values();
15695
Map<String, InferenceFieldMetadata> inferenceIndicesMetadata = new HashMap<>();

0 commit comments

Comments
 (0)