Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
392 views
in Technique[技术] by (71.8m points)

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. 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. 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. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.> Response: {"_index":"2020-01-13","_type":"_doc","_id":"15437","found":false}

question from:https://stackoverflow.com/questions/65940211/using-elasticsearch-nest-7-x-to-query-5-x-index

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...