我在 Elasticsearch 中有一个小型数据库,为了测试目的,我想要拉回所有记录。我尝试使用以下形式的 URL...
http://localhost:9200/foo/_search?pretty=true&q={'matchAll':{''}}
请问有人可以给我实现这个功能所需的URL吗?
我在 Elasticsearch 中有一个小型数据库,为了测试目的,我想要拉回所有记录。我尝试使用以下形式的 URL...
http://localhost:9200/foo/_search?pretty=true&q={'matchAll':{''}}
请问有人可以给我实现这个功能所需的URL吗?
_count
API来获取size
参数的值:http://localhost:9200/foo/_count?q=<your query>
{count:X, ...}
。提取值“X”,然后执行实际查询:http://localhost:9200/foo/_search?q=<your query>&size=X
调整大小的最佳方法是在URL前使用 size=数字
Curl -XGET "http://localhost:9200/logstash-*/_search?size=50&pretty"
很简单!你可以使用size
和from
参数!
http://localhost:9200/[your index name]/_search?size=1000&from=0
from
,直到获取所有的数据。from
+ size
不能超过索引设置的 index.max_result_window,默认为10,000。 - stelios从Kibana DevTools中,它是:
GET my_index_name/_search
{
"query": {
"match_all": {}
}
}
GET /address/_search
{
"_source": ["streetaddress","city","state","postcode"],
"size": 100,
"query":{
"match_all":{ }
}
}
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://localhost:9200/foo/_search/?size=1000&pretty=1
您需要指定“size”查询参数,因为默认值为10。
注:该链接为IT技术相关内容。size参数将默认显示10条结果的数量增加到500条。
http://localhost:9200/[索引名称]/_search?pretty=true&size=500&q=*:*
逐步更改from参数以获取所有数据。
http://localhost:9200/[索引名称]/_search?size=500&from=0
针对 Elasticsearch 6.x
请求: GET /foo/_search?pretty=true
响应: 在 Hits -> total 中,提供文档的计数。
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1001,
"max_score": 1,
"hits": [
{
Elasticsearch默认返回10条记录,因此需要明确提供大小。
在请求中添加大小以获取所需的记录数。
http://{host}:9200/{index_name}/_search?pretty=true&size=(记录数)
注意:最大页面大小不能超过index.max_result_window索引设置,该设置默认为10,000。
http://curl -XGET 'localhost:9200/foo/_search'
。 - Mr. N