When I query from elasticsearch, I get a response:
{
"took": 16,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
Is it possible to get the "took" value using spring data elasticsearch?
EDIT:
This is how we query to the elasticsearch:
SearchHits<SearchPo> findByAllAttributes(String searchText) {
return elasticsearchRestTemplate.search(buildHeaderSearchQuery(searchText),
SearchPo.class, IndexCoordinates.of("search");
You cannot retrieve that information using
ElasticsearchRestTemplate. As you can see from the code, thetookinformation is available insideSearchResponsebutSearchDocumentResponseBuilder.from(SearchResponse)doesn't make it available and only returns SearchHits.What you could do is sub-class
ElasticsearchRestTemplateand overload (not override!) thesearchmethod in order to return the rawSearchResponseso you can then callSearchResponse.getTook()from your code.Edit (by P.J.Meisch): Create an issue in Github to have this added to the
SearchHits<T>and feel free to contribute a pull request for that.