我尝试使用下面的代码检索索引的所有(elasticsearch)Id。
SearchRequest sr = SearchRequest.of(r -> r
.index("my_index")
.source(s -> s.fetch(false))
.size(10000));
System.out.println("Request: " + sr);
final SearchResponse<MyDoc> response;
try {
response = this.esClient.search(sr, MyDoc.class);
} catch (ElasticsearchException | IOException e) {
throw new MyException("fetch all ids: request failed: " + e.getMessage(), e);
}
System.out.println("Response: " + response);
响应中没有结果。但是,打印的请求
POST /my_index/_search?typed_keys=true {"_source":false,"size":10000}
它在作为REST请求直接运行时工作得非常好。
你知道如何使用Java客户端吗?
REST响应为
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 999,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "my_index",
"_id": "2LHJSP6dTjXuEM2vsEDyxdG4Y7HPzXL15tFvrkyZm8xn",
"_score": 1
},
{
"_index": "my_index",
"_id": "A8RCf2mV4qeWvLxSfzKNX418E734uEifCenoCAiM3syB",
"_score": 1
},
...
]
}
}
1条答案
按热度按时间vkc1a9a21#
也许这对你有用: