Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl http://localhost:9200/index/type/_search?pretty=true -d '
- {
- "query" : {
- "match_all" : {}
- },
- "stored_fields": []
- }
- '
- {
- "took" : 7,
- "timed_out" : false,
- "_shards" : {
- "total" : 5,
- "successful" : 5,
- "failed" : 0
- },
- "hits" : {
- "total" : 4,
- "max_score" : 1.0,
- "hits" : [ {
- "_index" : "index",
- "_type" : "type",
- "_id" : "36",
- "_score" : 1.0
- }, {
- "_index" : "index",
- "_type" : "type",
- "_id" : "38",
- "_score" : 1.0
- }, {
- "_index" : "index",
- "_type" : "type",
- "_id" : "39",
- "_score" : 1.0
- }, {
- "_index" : "index",
- "_type" : "type",
- "_id" : "34",
- "_score" : 1.0
- } ]
- }
- }
- curl http://localhost:9200/index/type/_search?pretty=true -d '
- {
- "query" : {
- "match_all" : {}
- },
- "fields": ["document_field_to_be_returned"]
- }
- '
- from elasticsearch import Elasticsearch
- from elasticsearch_dsl import Search
- es = Elasticsearch()
- s = Search(using=es, index=ES_INDEX, doc_type=DOC_TYPE)
- s = s.fields([]) # only get ids, otherwise `fields` takes a list of field names
- ids = [h.meta.id for h in s.scan()]
- GET http://localhost:9200/my_index/my_doc/_search?search_type=scan&scroll=5m [status:200 request:0.003s]
- GET http://localhost:9200/_search/scroll?scroll=5m [status:200 request:0.005s]
- GET http://localhost:9200/_search/scroll?scroll=5m [status:200 request:0.005s]
- GET http://localhost:9200/_search/scroll?scroll=5m [status:200 request:0.003s]
- GET http://localhost:9200/_search/scroll?scroll=5m [status:200 request:0.005s]
- ...
- curl 'http://localhost:9200/index/type/_search?pretty=true&fields='
- GET /_search
- {
- "_source": false,
- "query" : {
- "term" : { "user" : "kimchy" }
- }
- }
- from elasticsearch import Elasticsearch
- from elasticsearch.helpers import scan
- es = Elasticsearch()
- for dobj in scan(es,
- query={"query": {"match_all": {}}, "fields" : []},
- index="your-index-name", doc_type="your-doc-type"):
- print dobj["_id"],
- import elasticsearch
- es = elasticsearch.Elasticsearch()
- res = es.search(
- index=your_index,
- body={"query": {"match_all": {}}, "size": 30000, "fields": ["_id"]})
- ids = [d['_id'] for d in res['hits']['hits']]
- from elasticsearch import Elasticsearch,helpers
- es = Elasticsearch(hosts=[YOUR_ES_HOST])
- a=helpers.scan(es,query={"query":{"match_all": {}}},scroll='1m',index=INDEX_NAME)#like others so far
- IDs=[aa['_id'] for aa in a]
- Url -> http://localhost:9200/<index>/<type>/_query
- http method -> DELETE
- Query -> {"query": {"match_all": {}}, "size": 30000, "fields": ["_id"]})
Add Comment
Please, Sign In to add comment