ElasticSearch多卷Java API [英] ElasticSearch Multiple Scrolls Java API
问题描述
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
)是设计的。超时已过期(每次通话后都会重新设置)弹性搜索扫描和滚动 - 添加到新索引)。
所以每个索引只能得到一个打开的滚动条。
https://www.elastic.co/guide/en/elasticsearch/reference/current /search-request-scroll.html 指出:
滚动不适用于实时用户请求,而是用于
处理大量数据,例如为了将一个索引的
内容重新索引到具有不同配置的新索引。
所以看起来我是想要的不是一个选项,可能是因为优化。
更新
如所述创建多个卷轴不能完成,但是只有当您用于滚动的查询是相同的时才是这样。如果滚动
,例如另一个类型
, index
或另一个查询
,您可以有多个滚动
I want to get all data from an index. Since the number of items is too large for memory I use the Scroll (nice function):
client.prepareSearch(index)
.setTypes(myType).setSearchType(SearchType.SCAN)
.setScroll(new TimeValue(60000))
.setSize(amountPerCall)
.setQuery(MatchAll())
.execute().actionGet();
Which works nice when calling:
client.prepareSearchScroll(scrollId)
.setScroll(new TimeValue(600000))
.execute().actionGet()
But, when I call the former method multiple times, I get the same scrollId
multiple times, hence I cannot scroll multiple times - in parallel.
I found http://elasticsearch-users.115913.n3.nabble.com/Multiple-scrolls-simultanious-td4024191.html which states that it is possible - though I don't know his affiliation to ES.
Am I doing something wrong?
After searching some more, I got the impression that this (same scrollId
) is by design. After the timeout has expired (which is reset after each call Elasticsearch scan and scroll - add to new index).
So you can only get one opened scroll per index.
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html states:
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.
So it appears what I wanted is not an option, on purpose - possibly because of optimization.
Update
As stated creating multiple scrolls cannot be done, but this is only true when the query you use for scrolling is the same. If you scroll
for, for instance, another type
, index
, or just another query
, you can have multiple scrolls
这篇关于ElasticSearch多卷Java API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!