I want to implement this command using the new ES Java API client but the result shows source
as null
POST /test_event_202207/_search?typed_keys=true
{
"sort":[{"time":{"order":"desc"}}]
}
If I excecute this in Kibana, source
is not null.
Does anyboby encounter this kind of problem?
Below is my code:
SearchRequest searchRequest = SearchRequest.of(r -> r
.index("test_event_202207")
.sort(s->s.field(f->f.field("time").order(SortOrder.Desc)))
);
final SearchResponse response;
try {
response = esClient.search(searchRequest, Void.class);
} catch (final IOException e) {
throw new UncheckedIOException(e);
}
List<Hit> listSearchHit = response.hits().hits();
Optional<Hit> searchHit = listSearchHit.stream().findFirst();
When you check the searchHit variable, it is null....