Browse Source

Fix potential issue with graph api's timed out field in response. (#91006)

Graph explore transport action should check the search response's timed
out field and set its own time out flag accordingly.

Relates to #90286
Martijn van Groningen 3 years ago
parent
commit
12c81d1b59

+ 5 - 0
docs/changelog/91006.yaml

@@ -0,0 +1,5 @@
+pr: 91006
+summary: Fix potential issue with graph api's timed out field in response
+area: Graph
+type: bug
+issues: []

+ 6 - 4
x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java

@@ -171,13 +171,15 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
         /**
          * Step out from some existing vertex terms looking for useful
          * connections
+         *
+         * @param timedOut the value of timedOut field in the search response
          */
-        synchronized void expand() {
+        synchronized void expand(boolean timedOut) {
             Map<String, Set<Vertex>> lastHopFindings = hopFindings.get(currentHopNumber);
             if ((currentHopNumber >= (request.getHopNumbers() - 1)) || (lastHopFindings == null) || (lastHopFindings.size() == 0)) {
                 // Either we gathered no leads from the last hop or we have
                 // reached the final hop
-                listener.onResponse(buildResponse(false));
+                listener.onResponse(buildResponse(timedOut));
                 return;
             }
             Hop lastHop = request.getHop(currentHopNumber);
@@ -352,7 +354,7 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
                     }
 
                     // Potentially run another round of queries to perform next"hop" - will terminate if no new additions
-                    expand();
+                    expand(searchResponse.isTimedOut());
 
                 }
 
@@ -715,7 +717,7 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
                             }
                         }
                         // Expand out from these root vertices looking for connections with other terms
-                        expand();
+                        expand(searchResponse.isTimedOut());
 
                     }