简体   繁体   English

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

[英]Using Elasticsearch Nest 7.x to query 5.x index

I have a project using Nest 7.x and there is a query I need to make to an older 5.x elasticsearch index.我有一个使用 Nest 7.x 的项目,我需要对较旧的 5.x elasticsearch 索引进行查询。 When I make a call like this, I get the following error.当我这样打电话时,出现以下错误。 I am guessing it is due to how the mapping types were changed in version 6 and greater.我猜这是由于映射类型在第 6 版及更高版本中发生了变化。 Is there any way around this to query an older index?有什么办法可以查询旧索引吗?

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.从 GET 上的成功 (404) 低级调用构建的无效 NEST 响应:/myindex/_doc/15437 请求:<请求 stream 未被序列化程序捕获或已读取完成。 Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.> Response: {"_index":"2020-01-13","_type":"_doc","_id":"15437","found":false}在 ConnectionSettings 上设置 DisableDirectStreaming() 以强制在响应中设置它。> Response: {"_index":"2020-01-13","_type":"_doc","_id":"15437","found “:错误的}

As a workaround, I did this and it appears to work.作为解决方法,我这样做了,它似乎有效。 Not sure if there are any better solutions?不确定是否有更好的解决方案?

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"))
                        )
                    )
                )
            )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM