Thanks for the reply.
Is there any way to use ElasticsearchRepository which extends from PagingAndSortingRepository. This allows built-in support for pagination and sorting.
But I am not able to change my implementation to use ElasticsearchRepository. I just want to know how to apply:
How to use Post Search
How to use esQuery which basically providing Search query
String esQuery = String.format(searchTextQuery, startDate, endDate, formattedQueries);
3 How to use that Post URI which I m getting as below:
Request request = new Request("GET", "/" + user.getUserId() + "/_search");
So with all above how to use Pagination with ElasticsearchRepository
Ok but I have tried with High Level Rest client and with that kindly reply for below 2 points.
How to use pagination like here can see we have "from" and "size" parameters but what about "to". Without "to" how to navigate backwards. With "from" we can navigate forward a page and can't move to the backward page. Suppose we are in Page 10 and now want to move directly to the 4th page then how to move it.
With HighlevelClient:
Below is the implementation code:
method [POST], host [http://localhost:9200], URI [/0/_search?typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&search_type=query_then_fetch&batched_reduce_size=512], status line [HTTP/1.1 400 Bad Request]
{"error":{"root_cause":[{"type":"parsing_exception","reason":"[size] query malformed, no start_object after query name","line":2,"col":11}],"type":"parsing_exception","reason":"[size] query malformed, no start_object after query name","line":2,"col":11},"status":400}
Below is my query and getting result when trying with Low-Level Rest client and also working when using in Kibana tool:
POST /0/_search/
{
"size": 1000,
"query": {
"bool": {
"must": [
{
"nested": {
"path": "history",
"query": {
"range": {
"history.responseDate": {
"gte": "2019-12-31T18:30Z",
"lte": "2020-12-31T18:29:59.999Z"
}
}
}
}
},
{
"nested": {
"path": "history",
"query": {
"nested": {
"path": "history.sections",
"query": {
"nested": {
"path": "history.sections.historyquess",
"query": {
"nested": {
"path": "history.sections.historyquess.ques",
"query": {
"nested": {
"path": "history.sections.historyquess.ques.ans",
"query": {
"exists": {
"field": "history.sections.historyquess.ques.ans.other"
}
}
}
}
}
}
}
}
}
}
}
}
]
}
},
"_source": [
"history.sections.historyquess.ques.ans.other",
"history.sections.historyquess.ques.title"
]
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.