Advertisement
Guest User

shard cache script

a guest
Feb 17th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.31 KB | None | 0 0
  1. #!/bin/sh
  2. echo "Get ES version:"
  3. curl localhost:9200
  4.  
  5. echo "Remove old index..."
  6. curl -XDELETE "http://localhost:9200/shardcache?pretty=true"
  7.  
  8. echo "Make index and add some data - default mappings are fine"
  9. curl -XPOST "http://localhost:9200/shardcache/type/1?pretty=true" -d '
  10. {
  11.      "tweet":"Obama",
  12.      "created_at":"2012-01-01T00:00:00Z",
  13.      "created_at2":"2012-01-01T00:00:00Z"
  14. }
  15. '
  16. curl -XPOST "http://localhost:9200/shardcache/type/2?pretty=true" -d '
  17. {
  18.      "tweet":"Obama",
  19.      "created_at":"2016-01-01T00:00:00Z",
  20.      "created_at2":"2012-01-01T00:00:00Z"
  21. }
  22. '
  23.  
  24. echo "Wait for ES to be synced (aka refresh indices)..."
  25. curl -XPOST "http://localhost:9200/shardcache/_refresh?pretty=true"
  26.  
  27. echo "Enable query cache by default"
  28. curl -XPUT localhost:9200/shardcache/_settings?pretty -d'{ "index.cache.query.enable": true }'
  29.  
  30. echo "Show settings: verify query cache enabled"
  31. curl -GET localhost:9200/shardcache/_settings?pretty
  32.  
  33. echo "Verify empty cache..."
  34. curl 'localhost:9200/shardcache/_stats/query_cache?pretty&human'
  35.  
  36.  
  37. echo "internal date range filtered agg..."
  38. # caching doesn't work with internal date range filter agg
  39. curl -XPOST "http://localhost:9200/shardcache/_search?pretty=true&search_type=count" -d '
  40. {
  41.    "query": {
  42.    "filtered": {
  43.      "filter": {
  44.        "bool": {
  45.          "must": [
  46.            {
  47.              "range": {
  48.                "created_at2": {
  49.                  "gte": "2012-01-01T00:00:00Z",
  50.                  "lte": "2016-01-01T00:00:00Z"
  51.                }
  52.              }
  53.            }
  54.          ]
  55.        }
  56.      }
  57.    }
  58.  },
  59.  "aggs": {
  60.     "tweets_per_day": {
  61.      "date_histogram": {
  62.        "field": "created_at",
  63.        "interval": "day"
  64.      }
  65.    }
  66.  }
  67. }
  68. '
  69.  
  70. echo "Verify empty cache..."
  71. curl 'localhost:9200/shardcache/_stats/query_cache?pretty&human'
  72.  
  73. echo "Running without date filter..."
  74. curl -XPOST "http://localhost:9200/shardcache/_search?search_type=count&pretty" -d '
  75. {
  76.  "aggs": {
  77.     "tweets_per_day": {
  78.      "date_histogram": {
  79.        "field": "created_at",
  80.        "interval": "day"
  81.      }
  82.    }
  83.  }
  84. }
  85. '
  86.  
  87. echo "Now verify something in the cache:"
  88. curl 'localhost:9200/shardcache/_stats/query_cache?pretty&human'
  89.  
  90. #echo "Clear cache..."
  91. #curl -XPOST 'localhost:9200/_cache/clear?query_cache=true'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement