1
0
Эх сурвалжийг харах

Fix profiling when kNN is nested with inner_hits (#103997)

The assertion here:

https://github.com/elastic/elasticsearch/blob/38867b7fb6fe88210064e19cc80d98df0ddce2f7/server/src/main/java/org/elasticsearch/search/fetch/FetchSearchResult.java#L64

Assumes that profiling should never be overridden. However, when using
kNN & inner_hits we execute separate fetch phases for those inner_hits.
To prevent this assertion, I propose we have the inner hits context
return `null` for the profiler. The top level profiler is all we care
about with `fetch` and that is what we return to the user.

NOTE: Since this is an assertion, and the top-level fetch is unaffected,
production environments aren't effected by the original bug nor by this
fix.

closes: https://github.com/elastic/elasticsearch/issues/103985
Benjamin Trent 1 жил өмнө
parent
commit
04b472263c

+ 21 - 0
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.vectors/100_knn_nested_search.yml

@@ -134,3 +134,24 @@ setup:
   - match: {hits.hits.0._id: "3"}
   - match: {hits.hits.0.fields.name.0: "rabbit.jpg"}
   - match: {hits.hits.0.inner_hits.nested.hits.hits.0.fields.nested.0.paragraph_id.0: "0"}
+---
+"nested kNN search inner_hits & profiling":
+  - skip:
+      version: ' - 8.12.99'
+      reason: 'bugfix for inner_hits and profiling in 8.13'
+  - do:
+      search:
+        index: test
+        body:
+          profile: true
+          _source: false
+          fields: [ "name" ]
+          knn:
+            field: nested.vector
+            query_vector: [-0.5, 90.0, -10, 14.8, -156.0]
+            k: 3
+            num_candidates: 3
+            inner_hits: {size: 1, fields: ["nested.paragraph_id"], _source: false}
+
+  - match: {hits.total.value: 3}
+  - is_true : profile

+ 6 - 0
server/src/main/java/org/elasticsearch/search/fetch/subphase/InnerHitsContext.java

@@ -25,6 +25,7 @@ import org.elasticsearch.search.SearchHit;
 import org.elasticsearch.search.internal.SearchContext;
 import org.elasticsearch.search.internal.SubSearchContext;
 import org.elasticsearch.search.lookup.Source;
+import org.elasticsearch.search.profile.Profilers;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -88,6 +89,11 @@ public final class InnerHitsContext {
             return name;
         }
 
+        @Override
+        public Profilers getProfilers() {
+            return null;
+        }
+
         @Override
         public InnerHitsContext innerHits() {
             return childInnerHits;