Hi all, i'm new to elastic. I'm using latest version ( 5.2 )
I have a problem: if i search for all data in an index using HTTP REST, i receive the correct JSON with the desired data with all fields, like this:
"hits": {
"total": 2540620,
"max_score": 1,
"hits": [
{
"_index": "my_elastic_index",
"_type": "data",
"_id": "AVrW0oxSraY5_uCR3s05",
"_score": 1,
"_source": {
"etl_timestamp": "2015-03-03T15:10:00.000Z",
"ggsn_mcc_mnc": "240",
"ggsn_ip_address": "62.140.134.92",
"data_center": null,
"bytes_transferred_output": 42,
"bytes_transferred_in....
I want to return all fields like the example above, but unfortunately i can't with my code. What's wrong with?
Settings settings = Settings.builder().put("cluster.name", "my_elastic_index").build();
TransportClient client = new PreBuiltTransportClient(settings).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));
SearchResponse scrollResp = client.prepareSearch("diameter_metrics").setQuery(QueryBuilders.matchAllQuery()).setTypes("data").setSize(10000).setScroll(new TimeValue(60000)).get();
do {
for (SearchHit hit : scrollResp.getHits().getHits()) {
System.out.println(hit.getFields());
}
scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(60000)).execute().actionGet();
} while (scrollResp.getHits().getHits().length != 0); // Zero hits
// mark the
// end of the
// scroll and
// the while
// loop.
thanks in advice.