Advertisement
VladimirLavrenchuk

new index

Feb 1st, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.34 KB | None | 0 0
  1. curl -X PUT localhost:9200/test -s -H 'Content-Type: application/json' -d'{
  2.    "settings" : {
  3.        "number_of_shards" : 1
  4.    },
  5.    "mappings" : {
  6.        "objects" : {
  7.            "properties" : {
  8.                "name" : {
  9.                  "fields": {
  10.                    "_raw":{
  11.                      "type":"keyword"
  12.                    }
  13.                  },
  14.                  "type" : "text"
  15.                },
  16.                "timestamp": {
  17.                  "type": "date"
  18.                },
  19.                "some":{
  20.                  "type":"integer"
  21.                }
  22.            }
  23.        }
  24.    }
  25. }'
  26.  
  27. for i in $(seq 10010); do curl -X POST localhost:9200/test/objects -s -H 'Content-Type: application/json' -d@- <<EOF
  28. {
  29.   "name":"John Doe #$i",
  30.   "timestamp":"$(date --iso-8601=seconds)",
  31.   "some": "$(( ( RANDOM % 1000 )  + 1 ))"
  32. }
  33. EOF
  34. done
  35.  
  36. for i in $(seq 10); do echo $i;done
  37.  
  38. curl localhost:9200/test/_mapping/objects?pretty=true
  39.  
  40. curl localhost:9200/test/objects/_count?pretty=true
  41.  
  42. curl localhost:9200/test/objects/qjgOqGgB_fSxOh8QCTQm
  43.  
  44. curl localhost:9200/test/objects/_search?pretty=true -s -H 'Content-Type: application/json' -d'
  45. {
  46.  "size" : 0,
  47.  "aggs" : {
  48.      "my_buckets": {
  49.          "composite" : {
  50.              "sources" : [
  51.                  { "duplicate": { "terms" : { "field": "name._raw" } } }
  52.              ]
  53.          },
  54.          "aggs": {
  55.            "filter": {
  56.              "bucket_selector": {
  57.                "buckets_path": {
  58.                  "doc_count": "_count"
  59.                },
  60.                "script": "params.doc_count > 2"
  61.              }
  62.           }
  63.        }
  64.     }
  65.  }
  66. }'
  67.  
  68. curl localhost:9200/test/objects/_search?pretty=true -s -H 'Content-Type: application/json' -d'
  69. {
  70.  "size" : 0,
  71.  "aggs" : {
  72.      "my_buckets": {
  73.          "composite" : {
  74.              "sources" : [
  75.                  { "duplicate": { "terms" : { "field": "name._raw" } } }
  76.              ],
  77.              "after": { "duplicate": "John Doe #10" }
  78.          },
  79.          "aggs": {
  80.            "filter": {
  81.              "bucket_selector": {
  82.                "buckets_path": {
  83.                  "doc_count": "_count"
  84.                },
  85.                "script": "params.doc_count > 2"
  86.              }
  87.           }
  88.        }
  89.     }
  90.  }
  91. }'
  92.  
  93. curl -X DELETE localhost:9200/test
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement