简体   繁体   English

如何更改NEST(ElasticSearch)滚动请求的索引?

[英]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.

相关问题 如何为ElasticSearch 5.x使用NEST流畅的映射指定索引/字段分析器? - How can I specify index / field analyzers using NEST fluent mapping for ElasticSearch 5.x? 如何使用NEST为Elasticsearch指定索引? - How do I specify an index for Elasticsearch using NEST? 如何使用C#使用Nest Elasticsearch编写查询? - How can i write a query by using Nest Elasticsearch by C# ? 如何访问在 Elasticsearch 上使用 NEST 进行的查询中的脚本字段? - How can I access script fields in queries made with NEST on Elasticsearch? Elasticsearch 巢6.5.1。 如何将原始请求发送到 Elasticsearch - Elasticsearch Nest 6.5.1. How do I get the Raw Request being sent to Elasticsearch ElasticSearch 中的索引映射请求使用 C# 中的 NEST - Index mapping request in ElasticSearch using NEST in C# 我如何使用Nest API 5在Elasticsearch中进行重新索引以从Elastic Search 1.4迁移到ElasticSearch 5 - How can i do reindexing in elasticsearch to migrate from elastic search 1.4 to elasticsearch 5 using Nest api 5 如何使用 NEST 更新 ElasticSearch 索引中的现有文档? - How do I update an existing document inside ElasticSearch index using NEST? EEST的ElasticSearch索引/插入失败 - ElasticSearch Index/Insert with NEST fail 在远程索引上使用Elasticsearch NEST - Using elasticsearch NEST on a remote index
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM