使用 Elasticsearch Nest 7.x 查询 5.x 索引

Using Elasticsearch Nest 7.x to query 5.x index

我有一个使用 Nest 7.x 的项目,我需要对较旧的 5.x elasticsearch 索引进行查询。当我这样打电话时,出现以下错误。我猜这是由于映射类型在第 6 版及更高版本中发生了变化。有什么办法可以查询旧索引吗?

var result = _elasticClient.GetAsync<Category>(id)

Invalid NEST response built from a successful (404) low level call on GET: /myindex/_doc/15437 Request: <Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.> Response: {"_index":"2020-01-13","_type":"_doc","_id":"15437","found":false}

作为一种变通方法,我这样做了,它似乎奏效了。不确定是否有更好的解决方案?

var response = _elasticClient.SearchAsync<Category>(s => s
                .Query(q => q
                    .Bool(b => b
                        .Must(
                            bs => bs.Term(p => p.Id, id),
                            bs => bs.Term(p => p.Field("_type").Value("category"))
                        )
                    )
                )
            )