![](/img/trans.png)
[英]ElasticSearch: is there a way to get new documents inserted in all indexes after a previous SearchRequest?
[英]Get all documents from an index - elasticsearch
如何在Elasticsearch中從索引中獲取所有文檔而不確定查詢的大小
GET http://localhost:8090/my_index/_search?size=1000&scroll=1m&pretty=true'-d '{"size": 0,"query":{"query_string":{ "match_all" : {}}}}
謝謝
根據ES 掃描查詢文檔 , size
參數不僅僅是結果數:
size參數允許您配置每批結果返回的最大匹配數。 每次對滾動API的調用都會返回下一批結果,直到沒有其他要返回的結果為止,即hits數組為空。
要檢索所有結果,您需要按照上述文檔中所述的方式對API進行后續調用,或者使用某些現成的實現(例如python中的實現) 。 這是一個示例腳本,用於在stdout上轉儲生成的json:
import elasticsearch
from elasticsearch.helpers import scan
import json
es = elasticsearch.Elasticsearch('https://localhost:8090')
es_response = scan(
es,
index='my_index',
doc_type='my_doc_type',
query={"query": { "match_all" : {}}}
)
for item in es_response:
print(json.dumps(item))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.