Caching a search query for pagination

When paginating through a query using "from" and "size", does the query stay cached, or is it evaluated anew each time on the server?

If not, is there a way to "freeze" a query to paginate it?
example:

curl -XPOST 'http://localhost:9200/index1/type1/_search' -d '{
"query":{"match_all":{}},
"sort":{
"_script" :{"script" : "Math.random()",
"type" : "number",
"order" : "asc"}},
"from":0,"size":10}'

Next time i run this, say with "from":10,"size":10, the ordering will be created anew, right? so i might even get duplicates between the two calls?

This seems an awful waste of CPU if all I want is to paginate through a query.

Look into the scroll feature, which might be a better solution for your use
case: Elasticsearch Platform — Find real-time answers at scale | Elastic

But to answer your question, the query is not cached and will be executed.
Queries are never cached, even if the parameters remain the same. Filters
can be cached.

--
Ivan

On Mon, May 13, 2013 at 1:35 AM, eranid eranid@gmail.com wrote:

When paginating through a query using "from" and "size", does the query
stay
cached, or is it evaluated anew each time on the server?

If not, is there a way to "freeze" a query to paginate it?
example:

curl -XPOST 'http://localhost:9200/index1/type1/_search' -d '{
"query":{"match_all":{}},
"sort":{
"_script" :{"script" : "Math.random()",
"type" : "number",
"order" : "asc"}},
"from":0,"size":10}'

Next time i run this, say with "from":10,"size":10, the ordering will be
created anew, right? so i might even get duplicates between the two calls?

This seems an awful waste of CPU if all I want is to paginate through a
query.

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Caching-a-search-query-for-pagination-tp4034705.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

That's really great! Thanks alot.

Regarding caching queries, I saw that you can set the _cache when using a filter, http://www.elasticsearch.org/guide/reference/query-dsl/query-filter/, but I do not see how I can later use that cached filter in another query?

The filter cache is applied behind the scenes, out of the developers
control.

--
Ivan

On Tue, May 14, 2013 at 7:39 AM, eranid eranid@gmail.com wrote:

That's really great! Thanks alot.

Regarding caching queries, I saw that you can set the _cache when using a
filter,
Elasticsearch Platform — Find real-time answers at scale | Elastic, but
I
do not see how I can later use that cached filter in another query?

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Caching-a-search-query-for-pagination-tp4034705p4034797.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.