Unable To specify Range Query Record limit through java API in es 2.3.1


(balaji) #1

Hi everyone,

In Java API .....

//Elasticsearch 1.5.2 Code

Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name","elasticsearch").build();
transportClient = new TransportClient(settings);
transportClient = transportClient.addTransportAddress(
new InetSocketTransportAddress("ip adrress",9300));
For
//Elasticsearch 2.3.1 Code
Settings settings = Settings.settingsBuilder().pu("cluster.name","elasticsearch").build();
TransportClient transportClient = TransportClient.builder().settings(settings).buil().addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("ip address",9300)));

//Common code for 2.3.1 or 1.5.2
SearchRequestBuilder srb = transportClient.prepareSearch("indexname").setTypes("mappingname").setSearchType(SearchType.DFS_QUERY_THEN_FETCH);;
QueryBuilder queryDate=queryDate = QueryBuilders.rangeQuery("timeStamp").to("2016-06-27T23:59:59").from("2016-04-24T00:00:00");
srb.setQuery(queryDate);
SearchResponse searchResponse = srb.execute().actionGet();
//But srb.setFrom(0).setSize(Integer.MAX_VALUE).setExplain(true).execute().actionGet(); [Not Working]
SearchHit[] searchResults = searchResponse.getHits().getHits();
for (SearchHit searchHit : searchResults) {
System.out.println(searchHit.getSource().get("timeStamp");
}

Please anyone help me regarding this Range query size Java API ES2.3.1 .
Thanks in advance
Balu


(Xavier Facq) #2

Hi,

Why do you say [Not Working] ?

Because you don't have enought results ?
If yes, you should look at the scrool API :https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-request-scroll.html

And to the index setting : max_result_window


(system) #3

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