SearchDescriptor.Type Nest 中缺少方法 7.x

SearchDescriptor.Type method is missing in Nest 7.x

目前,我们使用的是 Nest 库版本 5.x。由于我们认为 Nest 7.x 更快,我们计划将版本从 5.x 升级到 7.x。在升级库版本时,我发现 Nest 版本 7.x 中缺少一些方法。

我们有Listings和Listing两个索引。 Listings 是 Listing 的父 Index(例如:Listings/Listing/_search)。我们有一个扩展 class 可以帮助与 Nest 交互。 class 有一个方法 Search,如代码部分所示。此方法使用 SearchDescriptor 的 Type 方法。 Next 7.x.

中缺少哪个
    public static async Task<ElasticsearchResult<ISearchResponse<T>>> SearchAsync<T>(
        this Elasticsearch elasticsearchClient,
        SearchDescriptor<T> searchDescriptor, 
        int from = MinResultWindowSize, 
        int to = MaxResultWindowSize) where T : class
    {
        return await Elasticsearch.PerformTaskWithExceptionHandlingAsync(async () =>
        {
            searchDescriptor
                .Index(Elasticsearch.MetaData.IndexMetaData.IndexName)
                .Type(Elasticsearch.MetaData.IndexMetaData.ParentIndexType)
                .From(from)
                .Size(to);

            var result = await Elasticsearch.Client.SearchAsync<T>(searchDescriptor).ConfigureAwait(false);
            if (!result.IsValid)
            {
                throw new ElasticsearchClientException(result.DebugInformation ??
                                                        result.ApiCall?.OriginalException?.Message ??
                                                       "Debug information not available in response.");
            }

            return ElasticsearchResult.Ok(result);

        }).ConfigureAwait(false);
    }

我需要帮助来替换上面的代码,以便它与 Nest 兼容 7.x。

NEST 7.x 中缺少类型方法,因为 types are deprecated in Elasticsearch 7.x, as part of the roadmap for the removal of mapping types.

请注意 7.x clients are compatible only with Elasticsearch 7.x,因此如果您使用的是 Elasticsearch 5.x,则应坚持使用最新的 NEST 5.x 客户端版本。