mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 13:08:29 +00:00
38f5cc236a
In order to be more consistent with what they do, the query cache has been renamed to request cache and the filter cache has been renamed to query cache. A known issue is that package/logger names do no longer match settings names, please speak up if you think this is an issue. Here are the settings for which I kept backward compatibility. Note that they are a bit different from what was discussed on #11569 but putting `cache` before the name of what is cached has the benefit of making these settings consistent with the fielddata cache whose size is configured by `indices.fielddata.cache.size`: * index.cache.query.enable -> index.requests.cache.enable * indices.cache.query.size -> indices.requests.cache.size * indices.cache.filter.size -> indices.queries.cache.size Close #11569
77 lines
1.9 KiB
Plaintext
77 lines
1.9 KiB
Plaintext
|
|
[[caching-heavy-aggregations]]
|
|
== Caching heavy aggregations
|
|
|
|
Frequently used aggregations (e.g. for display on the home page of a website)
|
|
can be cached for faster responses. These cached results are the same results
|
|
that would be returned by an uncached aggregation -- you will never get stale
|
|
results.
|
|
|
|
See <<shard-request-cache>> for more details.
|
|
|
|
[[returning-only-agg-results]]
|
|
== Returning only aggregation results
|
|
|
|
There are many occasions when aggregations are required but search hits are not. For these cases the hits can be ignored by
|
|
setting `size=0`. For example:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
$ curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '{
|
|
"size": 0,
|
|
"aggregations": {
|
|
"my_agg": {
|
|
"terms": {
|
|
"field": "text"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
'
|
|
--------------------------------------------------
|
|
|
|
Setting `size` to `0` avoids executing the fetch phase of the search making the request more efficient.
|
|
|
|
[[agg-metadata]]
|
|
== Aggregation Metadata
|
|
|
|
You can associate a piece of metadata with individual aggregations at request time that will be returned in place
|
|
at response time.
|
|
|
|
Consider this example where we want to associate the color blue with our `terms` aggregation.
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
{
|
|
...
|
|
aggs": {
|
|
"titles": {
|
|
"terms": {
|
|
"field": "title"
|
|
},
|
|
"meta": {
|
|
"color": "blue"
|
|
},
|
|
}
|
|
}
|
|
}
|
|
--------------------------------------------------
|
|
|
|
Then that piece of metadata will be returned in place for our `titles` terms aggregation
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
{
|
|
...
|
|
"aggregations": {
|
|
"titles": {
|
|
"meta": {
|
|
"color" : "blue"
|
|
},
|
|
"buckets": [
|
|
]
|
|
}
|
|
}
|
|
}
|
|
--------------------------------------------------
|