Hi,
I need to extract data from elasticsearch with java but this return an main exception
while(true){
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
SearchRequestBuilder srb2 = client
.prepareSearch().setQuery(QueryBuilders.matchQuery("Time",0)).setSize(1);
MultiSearchResponse sr = client.prepareMultiSearch().add(srb2).get();
for (MultiSearchResponse.Item item : sr.getResponses()) {
SearchResponse response = item.getResponse();
for(int i = 0; i < response.getHits().getTotalHits(); i ++){
SearchHit sHit = response.getHits().getAt(i);
SearchHits sHits = response.getHits();
SearchHit[] sHitList = response.getHits().getHits();
for(SearchHit sHitItem : sHitList){
System.out.println("sHitItem ==> "+sHitItem.getSourceAsString());
Data data = ConvertConfig.ConvertToData(sHitItem.getSourceAsString());
data.setId(sHitItem.getId());
RowData row = Prediction.predictionData(data);
System.out.print("\t "+row.get("Classe").toString());
}
}
}
client.close();
}
error:
Exception in thread "main" Class probabilities: 0java.lang.ArrayIndexOutOfBoundsException: 1
at org.elasticsearch.search.SearchHits.getAt(SearchHits.java:117)
at com.backend.project.BackendProject.main(BackendProject.java:57)
any help please
thank you