[英]How can I change the index of a NEST (ElasticSearch) scroll request?
We have two indexes for each document type, a draft and a published index. 对于每种文档类型,我们都有两个索引,即草稿索引和已发布索引。 Normally setting the index we want to work with is easy but I can't see how to do it with the scroll API.
通常,设置我们要使用的索引很容易,但是我看不到如何使用滚动API。
The initial request is ok. 初始请求可以。
var query = new SearchDescriptor<MyDoc>()
.Index(MyDoc.DraftIndexName) <-- we can switch them here
// Or .Index(MyDoc.PublishedIndexName)
.Size(pageSize)
.Query(q =>
...
))
.Scroll("2m");
but when I want to get the next page 但是当我想获得下一页时
var request = new ScrollDescriptor<MyDoc>()
.ScrollId(scrollId)
.Scroll(new Time("2m"));
// Nowhere to set the index
var scrollResponse = await client.ScrollAsync<EsPerson>(request);
I assume it will always use the default index via inference which is the draft one. 我假设它将始终通过推断使用默认索引,即草稿。
The start of scrolling is initiated with a request to the search API, which returns a scroll ID in the response. 滚动开始是通过对搜索API的请求而发起的,搜索API在响应中返回滚动ID。 After that, the scroll ID from a response is passed to the scroll API to continue scrolling through all documents, repeating until no more documents are returned.
之后,来自响应的滚动ID会传递给滚动API,以继续滚动所有文档,重复直到不再返回任何文档。 All subsequent scroll API calls will use the configuration of the initial API call, including the index/indices targeted.
所有后续滚动API调用将使用初始API调用的配置,包括目标索引。
If scrolling is considered to be like a server-side cursor, where the initial request defines the parameters for scrolling, it doesn't make much sense to be able to change these parameters mid-scroll . 如果滚动被视为类似于服务器端游标,则初始请求定义了滚动参数,因此能够在mid-scroll中更改这些参数没有多大意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.