Skip to content

Instantly share code, notes, and snippets.

@ppf2
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppf2/bfa38b8284e09c0740ad to your computer and use it in GitHub Desktop.
Save ppf2/bfa38b8284e09c0740ad to your computer and use it in GitHub Desktop.
query cache test
DELETE /shardcache
PUT /shardcache
{
"settings": {
"index.cache.query.enable": true
}
}
GET /shardcache/_settings
POST /shardcache/type/1
{
"tweet":"Obama",
"created_at":"2012-01-01T00:00:00Z",
"created_at2":"2012-01-01T00:00:00Z"
}
POST /shardcache/type/2
{
"tweet":"Obama",
"created_at":"2016-01-01T00:00:00Z",
"created_at2":"2012-01-01T00:00:00Z"
}
POST shardcache/_cache/clear
GET _nodes/stats?pretty
# at this point query cache is empty
# run this
GET /shardcache/_search?search_type=count
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"range": {
"created_at2": {
"gte": "2012-01-01T00:00:00Z",
"lte": "2016-01-01T00:00:00Z"
}
}
}
]
}
}
}
},
"aggs": {
"tweets_per_day": {
"date_histogram": {
"field": "created_at",
"interval": "day"
}
}
}
}
# still nothing in cache
GET _nodes/stats?pretty
# run this
GET /shardcache/_search?search_type=count
{
"aggs": {
"tweets_per_day": {
"date_histogram": {
"field": "created_at",
"interval": "day"
}
}
}
}
# now there is something in the cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment