Last active
August 29, 2015 14:11
-
-
Save nezda/c65dd66785d5f1e4dbd4 to your computer and use it in GitHub Desktop.
Agg query_cache not working with date filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Remove old index..." | |
curl -XDELETE "http://localhost:9200/fml?pretty=true" | |
echo "Make index and add some data - default mappings are fine" | |
curl -XPOST "http://localhost:9200/fml/widget/?pretty=true" -d ' | |
{ | |
"name": "uno", | |
"postDate" : "2009-11-15" | |
} | |
' | |
curl -XPOST "http://localhost:9200/fml/widget/?pretty=true" -d ' | |
{ | |
"name": "dos", | |
"postDate" : "2010-11-15" | |
} | |
' | |
curl -XPOST "http://localhost:9200/fml/widget/?pretty=true" -d ' | |
{ | |
"name": "tres", | |
"postDate" : "201-11-15" | |
} | |
' | |
echo "Wait for ES to be synced (aka refresh indices)..." | |
curl -XPOST "http://localhost:9200/fml/_refresh?pretty=true" | |
echo "Enable query cache by default" | |
curl -XPUT localhost:9200/fml/_settings -d'{ "index.cache.query.enable": true }' | |
echo "Show settings: verify query cache enabled" | |
curl -GET localhost:9200/fml/_settings?pretty | |
echo "Verify empty cache..." | |
curl 'localhost:9200/_stats/query_cache?pretty&human' | |
# echo "simple cached agg..." | |
#curl -XPOST "http://localhost:9200/fml/widget/_search?pretty=true&search_type=count&query_cache=true" -d ' | |
#{ | |
# "aggregations": { | |
# "names": { | |
# "terms": { | |
# "field": "name" | |
# } | |
# } | |
# } | |
#} | |
#' | |
# echo "cached, internally filtered agg..." | |
#curl -XPOST "http://localhost:9200/fml/widget/_search?pretty=true&search_type=count&query_cache=true" -d ' | |
#{ | |
# "aggregations": { | |
# "with_filter": { | |
# "filter": { | |
# "bool": { | |
# "must_not": [ | |
# { | |
# "terms": { | |
# "name": [ "tres" ] | |
# } | |
# } | |
# ] | |
# } | |
# }, | |
# "aggregations": { | |
# "names": { | |
# "terms": { | |
# "field": "name" | |
# } | |
# } | |
# } | |
# } | |
# } | |
#} | |
#' | |
#echo "query-filtered, cached agg..." | |
#curl -XPOST "http://localhost:9200/fml/widget/_search?pretty=true&search_type=count&query_cache=true" -d ' | |
#{ | |
# "query": { | |
# "filtered": { | |
# "filter": { | |
# "bool": { | |
# "must_not": [ | |
# { | |
# "terms": { | |
# "name": [ "tres" ] | |
# } | |
# } | |
# ] | |
# } | |
# } | |
# } | |
# }, | |
# "aggregations": { | |
# "names": { | |
# "terms": { | |
# "field": "name" | |
# } | |
# } | |
# }, | |
# "facets": { | |
# "case_tags": { | |
# "terms": { | |
# "field": "name" | |
# } | |
# } | |
# } | |
#} | |
#' | |
echo "internal date range filtered agg..." | |
# caching doesn't work with internal date range filter agg | |
curl -XPOST "http://localhost:9200/fml/widget/_search?pretty=true&search_type=count&query_cache=true" -d ' | |
{ | |
"aggregations": { | |
"with_filter": { | |
"filter": { | |
"bool": { | |
"_cache": true, | |
"must": [ | |
{ | |
"range": { | |
"_cache": true, | |
"postDate": { | |
"gte": "2009-11-15", | |
"lte": "2010-11-16" | |
} | |
} | |
} | |
] | |
} | |
}, | |
"aggregations": { | |
"names": { | |
"terms": { | |
"field": "name" | |
} | |
} | |
} | |
} | |
} | |
} | |
' | |
#echo "minimal date query-filtered, cached agg..." | |
## caching doesn't work with date range filter in query | |
#curl -XPOST "http://localhost:9200/fml/widget/_search?pretty=true&search_type=count&query_cache=true" -d ' | |
#{ | |
# "query": { | |
# "filtered": { | |
# "filter": { | |
# "bool": { | |
# "_cache": true, | |
# "must": [ | |
# { | |
# "range": { | |
# "_cache": true, | |
# "postDate": { | |
# "gte": "2009-11-15", | |
# "lte": "2010-11-16" | |
# } | |
# } | |
# } | |
# ] | |
# } | |
# } | |
# } | |
# }, | |
# "aggregations": { | |
# "names": { | |
# "terms": { | |
# "field": "name" | |
# } | |
# } | |
# } | |
#} | |
#' | |
echo "Verify non-empty cache..." | |
curl 'localhost:9200/_stats/query_cache?pretty&human' | |
#echo "Clear cache..." | |
#curl -XPOST 'localhost:9200/_cache/clear?query_cache=true' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment