gpt4 book ai didi

java - ElasticSearch 多卷轴 Java API

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:19:14 24 4
gpt4 key购买 nike

我想从索引中获取所有数据。由于项目的数量对于内存来说太大了,所以我使用了 Scroll(不错的功能):

client.prepareSearch(index)
.setTypes(myType).setSearchType(SearchType.SCAN)
.setScroll(new TimeValue(60000))
.setSize(amountPerCall)
.setQuery(MatchAll())
.execute().actionGet();

调用时效果很好:

client.prepareSearchScroll(scrollId)
.setScroll(new TimeValue(600000))
.execute().actionGet()

但是,当我多次调用前一个方法时,我多次获得相同的 scrollId,因此我无法并行滚动多次。

我找到了 http://elasticsearch-users.115913.n3.nabble.com/Multiple-scrolls-simultanious-td4024191.html这表明这是可能的——尽管我不知道他与 ES 的关系。

我做错了什么吗?

最佳答案

进一步搜索后,我的印象是这个(相同的 scrollId)是设计使然的。超时过期后(每次调用 Elasticsearch scan and scroll - add to new index 后重置)。

因此每个索引只能打开一个卷轴。

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html状态:

Scrolling is not intended for real time user requests, but rather for processing large amounts of data, e.g. in order to reindex the contents of one index into a new index with a different configuration.

所以看起来我想要的不是一个选项,故意的 - 可能是因为优化。

更新
如前所述,无法创建多个滚动条,但只有当您用于滚动条的查询相同时才会出现这种情况。如果您滚动,例如,另一个类型索引,或者只是另一个查询,您可以有多个滚动

关于java - ElasticSearch 多卷轴 Java API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30918412/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com