Guest User

Untitled

a guest
Dec 11th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. curl http://localhost:9200/index/type/_search?pretty=true -d '
  2. {
  3. "query" : {
  4. "match_all" : {}
  5. },
  6. "stored_fields": []
  7. }
  8. '
  9.  
  10. {
  11. "took" : 7,
  12. "timed_out" : false,
  13. "_shards" : {
  14. "total" : 5,
  15. "successful" : 5,
  16. "failed" : 0
  17. },
  18. "hits" : {
  19. "total" : 4,
  20. "max_score" : 1.0,
  21. "hits" : [ {
  22. "_index" : "index",
  23. "_type" : "type",
  24. "_id" : "36",
  25. "_score" : 1.0
  26. }, {
  27. "_index" : "index",
  28. "_type" : "type",
  29. "_id" : "38",
  30. "_score" : 1.0
  31. }, {
  32. "_index" : "index",
  33. "_type" : "type",
  34. "_id" : "39",
  35. "_score" : 1.0
  36. }, {
  37. "_index" : "index",
  38. "_type" : "type",
  39. "_id" : "34",
  40. "_score" : 1.0
  41. } ]
  42. }
  43. }
  44.  
  45. curl http://localhost:9200/index/type/_search?pretty=true -d '
  46. {
  47. "query" : {
  48. "match_all" : {}
  49. },
  50. "fields": ["document_field_to_be_returned"]
  51. }
  52. '
  53.  
  54. from elasticsearch import Elasticsearch
  55. from elasticsearch_dsl import Search
  56.  
  57. es = Elasticsearch()
  58. s = Search(using=es, index=ES_INDEX, doc_type=DOC_TYPE)
  59.  
  60. s = s.fields([]) # only get ids, otherwise `fields` takes a list of field names
  61. ids = [h.meta.id for h in s.scan()]
  62.  
  63. GET http://localhost:9200/my_index/my_doc/_search?search_type=scan&scroll=5m [status:200 request:0.003s]
  64. GET http://localhost:9200/_search/scroll?scroll=5m [status:200 request:0.005s]
  65. GET http://localhost:9200/_search/scroll?scroll=5m [status:200 request:0.005s]
  66. GET http://localhost:9200/_search/scroll?scroll=5m [status:200 request:0.003s]
  67. GET http://localhost:9200/_search/scroll?scroll=5m [status:200 request:0.005s]
  68. ...
  69.  
  70. curl 'http://localhost:9200/index/type/_search?pretty=true&fields='
  71.  
  72. GET /_search
  73. {
  74. "_source": false,
  75. "query" : {
  76. "term" : { "user" : "kimchy" }
  77. }
  78. }
  79.  
  80. from elasticsearch import Elasticsearch
  81. from elasticsearch.helpers import scan
  82. es = Elasticsearch()
  83. for dobj in scan(es,
  84. query={"query": {"match_all": {}}, "fields" : []},
  85. index="your-index-name", doc_type="your-doc-type"):
  86. print dobj["_id"],
  87.  
  88. import elasticsearch
  89. es = elasticsearch.Elasticsearch()
  90.  
  91. res = es.search(
  92. index=your_index,
  93. body={"query": {"match_all": {}}, "size": 30000, "fields": ["_id"]})
  94.  
  95. ids = [d['_id'] for d in res['hits']['hits']]
  96.  
  97. from elasticsearch import Elasticsearch,helpers
  98. es = Elasticsearch(hosts=[YOUR_ES_HOST])
  99. a=helpers.scan(es,query={"query":{"match_all": {}}},scroll='1m',index=INDEX_NAME)#like others so far
  100.  
  101. IDs=[aa['_id'] for aa in a]
  102.  
  103. Url -> http://localhost:9200/<index>/<type>/_query
  104. http method -> DELETE
  105. Query -> {"query": {"match_all": {}}, "size": 30000, "fields": ["_id"]})
Add Comment
Please, Sign In to add comment