3

Currently, We are using Nest library version 5.x. As we heart that Nest 7.x is faster, we planned to upgrade version from 5.x to 7.x. While upgrading the library version, I have found that some methods are missing in Nest version 7.x.

We have Listings and Listing two index. Listings is a parent Index of Listing (eg: Listings/Listing/_search). We have one extension class that help to interact with Nest. This class has one method Search as shown in the code section. This method is using Type method of SearchDescriptor. Which is missing in 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);
    }

I need help to replace the above code so that it will be compatible with Nest 7.x.

Arjun Bhalodiya
  • 293
  • 2
  • 14
  • `Type` was removed from NEST as elasticsearch is not supporting multi-type indices anymore. https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/nest-breaking-changes.html – Rob Jul 09 '19 at 09:53
  • Hi Rob, I already go through elastic search and nest document and I have found this as a breaking change. But we are using old elastic search we can't avoid this type. I have to find some alternate of this missing method. – Arjun Bhalodiya Jul 09 '19 at 14:50

1 Answers1

2

The type method is missing in NEST 7.x because types are deprecated in Elasticsearch 7.x, as part of the roadmap for the removal of mapping types.

Note that the 7.x clients are compatible only with Elasticsearch 7.x, so if you're using Elasticsearch 5.x, you should stick to the latest NEST 5.x client release.

Russ Cam
  • 124,184
  • 33
  • 204
  • 266