Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- echo "Get ES version:"
- curl localhost:9200
- echo "Remove old index..."
- curl -XDELETE "http://localhost:9200/shardcache?pretty=true"
- echo "Make index and add some data - default mappings are fine"
- curl -XPOST "http://localhost:9200/shardcache/type/1?pretty=true" -d '
- {
- "tweet":"Obama",
- "created_at":"2012-01-01T00:00:00Z",
- "created_at2":"2012-01-01T00:00:00Z"
- }
- '
- curl -XPOST "http://localhost:9200/shardcache/type/2?pretty=true" -d '
- {
- "tweet":"Obama",
- "created_at":"2016-01-01T00:00:00Z",
- "created_at2":"2012-01-01T00:00:00Z"
- }
- '
- echo "Wait for ES to be synced (aka refresh indices)..."
- curl -XPOST "http://localhost:9200/shardcache/_refresh?pretty=true"
- echo "Enable query cache by default"
- curl -XPUT localhost:9200/shardcache/_settings?pretty -d'{ "index.cache.query.enable": true }'
- echo "Show settings: verify query cache enabled"
- curl -GET localhost:9200/shardcache/_settings?pretty
- echo "Verify empty cache..."
- curl 'localhost:9200/shardcache/_stats/query_cache?pretty&human'
- echo "internal date range filtered agg..."
- # caching doesn't work with internal date range filter agg
- curl -XPOST "http://localhost:9200/shardcache/_search?pretty=true&search_type=count" -d '
- {
- "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"
- }
- }
- }
- }
- '
- echo "Verify empty cache..."
- curl 'localhost:9200/shardcache/_stats/query_cache?pretty&human'
- echo "Running without date filter..."
- curl -XPOST "http://localhost:9200/shardcache/_search?search_type=count&pretty" -d '
- {
- "aggs": {
- "tweets_per_day": {
- "date_histogram": {
- "field": "created_at",
- "interval": "day"
- }
- }
- }
- }
- '
- echo "Now verify something in the cache:"
- curl 'localhost:9200/shardcache/_stats/query_cache?pretty&human'
- #echo "Clear cache..."
- #curl -XPOST 'localhost:9200/_cache/clear?query_cache=true'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement