# How to debug Java GraphExploreRequestBuilder

**URL:** <https://discuss.elastic.co/t/how-to-debug-java-graphexplorerequestbuilder/103211>\
**Category:** Elasticsearch\
**Created:** [October 9, 2017, 10:17am UTC](https://discuss.elastic.co/t/how-to-debug-java-graphexplorerequestbuilder/103211 "2017-10-09T10:17:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Becker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martin_becker/32/22885_2.png) [@Martin\_Becker](https://discuss.elastic.co/u/Martin_Becker)\
**Post date:** [October 9, 2017, 10:17am UTC](https://discuss.elastic.co/t/how-to-debug-java-graphexplorerequestbuilder/103211/1 "2017-10-09T10:17:53Z")

</div>

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".

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [October 11, 2017, 9:43am UTC](https://discuss.elastic.co/t/how-to-debug-java-graphexplorerequestbuilder/103211/2 "2017-10-11T09:43:21Z")

</div>

> [@Martin\_Becker](#):
>
> Is there any possibility to see the actual query which is being generated?

Sorry, not as JSON, no.  
The equivalent JSON for your request should be:

```
POST YOUR_INDEX/YOUR_DOC_TYPES/_xpack/_graph/_explore
{
  "controls": {
	"use_significance": true,
	"sample_size": YOUR_SAMPLE_SIZE
  },
  "query": YOUR_QUERY
  "vertices": [
	{
	  "field": "artists",
	  "size": YOUR_NUMBER_OF_DOCS_PER_HOP,
	  "exclude": [YOUR_EXCLUDES]
	}
  ]
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 8, 2017, 9:43am UTC](https://discuss.elastic.co/t/how-to-debug-java-graphexplorerequestbuilder/103211/3 "2017-11-08T09:43:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
