在 Nest v7.10.0 中通过 SearchRequest 搜索特定的索引名称

Search in specific Index Name by SearchRequest in Nest v7.10.0

我在同一台服务器上有 2 个具有相同结构和不同索引名称的索引。 第一个是出于开发原因,第二个是出于 uat 原因。 我在 appsettings 中有两个索引名称,程序使用适当的取决于环境。 我想在 searchRequest 中声明索引名称,但在 Nest v7.10.0 searchRequest 中没有索引。


            ISearchRequest searchRequest = new SearchRequest
            {
                From = query.Payload.Paging?.Skip,
                Size = query.Payload.Paging?.Take ?? 10000,
                Sort = sortField != null ? new List<ISort> { sortField } : null,
                Query = new QueryContainer(boolQuery),
                Source = new SourceFilter
                {
                    Includes = Infer.Field<EventHistory>(path: eventHistory => eventHistory.Id)
                }
            };

            ISearchResponse<EventHistory> searchResponse = await _elasticClient.SearchAsync<EventHistory>(searchRequest);

构造函数接受一个 Indices 参数

ISearchRequest searchRequest = new SearchRequest("foo")
{
    
    From = query.Payload.Paging?.Skip,
    Size = query.Payload.Paging?.Take ?? 10000,
    Sort = sortField != null ? new List<ISort> { sortField } : null,
    Query = new QueryContainer(boolQuery),
    Source = new SourceFilter
    {
        Includes = Infer.Field<EventHistory>(path: eventHistory => eventHistory.Id)
    }
};

ISearchResponse<EventHistory> searchResponse = await _elasticClient.SearchAsync<EventHistory>(searchRequest);