我在Elasticsearch中有一个小数据库,出于测试目的,我想把所有记录拉回来。我正在尝试使用表单的URL…
http://localhost:9200/foo/_search?pretty=true&q={'matchAll':{''}}
有人能给我你要用来完成这个的URL吗?
我在Elasticsearch中有一个小数据库,出于测试目的,我想把所有记录拉回来。我正在尝试使用表单的URL…
http://localhost:9200/foo/_search?pretty=true&q={'matchAll':{''}}
有人能给我你要用来完成这个的URL吗?
当前回答
curl -X GET 'localhost:9200/foo/_search?q=*&pretty'
其他回答
使用python包elasticsearch-dsl的简单解决方案:
from elasticsearch_dsl import Search
from elasticsearch_dsl import connections
connections.create_connection(hosts=['localhost'])
s = Search(index="foo")
response = s.scan()
count = 0
for hit in response:
# print(hit.to_dict()) # be careful, it will printout every hit in your index
count += 1
print(count)
参见https://elasticsearch-dsl.readthedocs.io/en/latest/api.html#elasticsearch_dsl.Search.scan。
http://127.0.0.1:9200/foo/_search/?size=1000&pretty=1
^
请注意size参数,它将每个分片显示的命中数从默认值(10)增加到1000。
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-from-size.html
简单!你可以使用size和from参数!
http://localhost:9200/[your index name]/_search?size=1000&from=0
然后逐渐改变,直到你得到所有的数据。
使用server:9200/_stats也可以获得所有别名的统计信息。就像每个别名的大小和元素数量一样,这非常有用,并提供了有用的信息
Elasticsearch 6.x
请求:GET /foo/_search?漂亮= true
Response:在Hits-> total中,给出文档的计数
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1001,
"max_score": 1,
"hits": [
{