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.