# RequestOptions cannot be resolved to a variable

**URL:** <https://discuss.elastic.co/t/requestoptions-cannot-be-resolved-to-a-variable/143681>\
**Category:** Elasticsearch\
**Created:** [August 9, 2018, 11:48am UTC](https://discuss.elastic.co/t/requestoptions-cannot-be-resolved-to-a-variable/143681 "2018-08-09T11:48:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![agrawal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/agrawal/32/33850_2.png) [@agrawal](https://discuss.elastic.co/u/agrawal)\
**Post date:** [August 9, 2018, 11:48am UTC](https://discuss.elastic.co/t/requestoptions-cannot-be-resolved-to-a-variable/143681/1 "2018-08-09T11:48:14Z")

</div>

I am trying to search the data in ES using RestHighLevelClient and referring the documentation available at ([https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-search.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-search.html)) but getting a compilation error "RequestOptions cannot be resolved to a variable" at line "client.search(searchRequest, RequestOptions.DEFAULT);"  
Could you please let me know the right way to search the data using RestHighLevelClient.

ES version: 6.3.2

Code:

```
RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost", 9200, "http"))
                    .setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
                        public RequestConfig.Builder customizeRequestConfig(RequestConfig.Builder requestConfigBuilder) {
                            return requestConfigBuilder.setConnectTimeout(5000)
                                    .setSocketTimeout(100000);
                        }
                    })
            .setMaxRetryTimeoutMillis(100000)
        );
SearchRequest searchRequest = new SearchRequest("");
										  searchRequest.types("doc");
										  SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
										  searchSourceBuilder.query(QueryBuilders.matchAllQuery());
										  searchRequest.source(searchSourceBuilder);
										  SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
```

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [August 17, 2018, 11:21am UTC](https://discuss.elastic.co/t/requestoptions-cannot-be-resolved-to-a-variable/143681/2 "2018-08-17T11:21:54Z")

</div>

The problem here is that you're trying to use the master documentation against 6.3. Instead, you should be using the 6.3 [docs](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.3/java-rest-high-search.html). You can get to the 6.3 docs from the master docs by clicking the version drop down on the right-hand side of the page. If you follow this, you will see that `RequestOptions` is not referenced there (because we only added it in 6.4), and that instead the code you want is:

```java
SearchResponse searchResponse = client.search(searchRequest);

```

---

<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:** [September 14, 2018, 11:21am UTC](https://discuss.elastic.co/t/requestoptions-cannot-be-resolved-to-a-variable/143681/3 "2018-09-14T11:21:57Z")

</div>

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