Hello there.
I am writing a tool to query the Graph-API to get additional recommendations for customer choices. I wrote a function which takes some input parameters and creates a GraphExploreRequestBuilder, a Hop, a VertexRequest and more. I would like to see the JSON which is being generated and queried towards the API.
My function / class looks like this:
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.xpack.graph.action.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class GraphQueryFactory {
@Autowired
private Client client;
public GraphExploreResponse getGraph(
QueryBuilder queryBuilder,
Boolean useSignificance,
String index,
String fieldName,
List<String> excludes,
int numberOfDocsPerHop,
int sampleSize) {
GraphExploreRequestBuilder grb =
new GraphExploreRequestBuilder(this.client, GraphExploreAction.INSTANCE)
.setIndices(index)
.setTypes("create-event", "order-event");
Hop hop = grb.createNextHop(queryBuilder);
VertexRequest vex = hop.addVertexRequest(fieldName);
vex.size(numberOfDocsPerHop);
for(String exclude : excludes) {
vex.addExclude(exclude);
}
grb.useSignificance(useSignificance);
grb.sampleSize(sampleSize);
System.out.println("Graph query: " + grb.get());
return grb.get();
}
}
Is there any possibility to see the actual query which is being generated? I would like to compare it to the JSON which I can see in the GUI tool in Kibana Graph under "Settings > Latest request".