Dotnet Client(`Elastic.Clients.Elasticsearch`) doesn't support knn_search

I try to use elasticsearch knn_search feature in dotnet.
However, I don't think last stable version of es dotnet client Elastic.Clients.Elasticsearch(version 8.0.1) support knn_search.

I try to use Knn feature like code below but only got error below:

Sending Request in C# with ES Client 8.0.1

        var response = await _client.SearchAsync<ImageSearchDocument>(
            s => s
                .Knn(k => k

ES Error

{"error":{"root_cause":[{"type":"parsing_exception","reason":"Unknown key for a START_OBJECT in [knn].","line":1,"col":8}],"type":"parsing_exception","reason":"Unknown key for a START_OBJECT in [knn].","line":1,"col":8},"status":400}

The reason above is because the url is using _search instead of _knn_search. I tried to run the same request on the postman and it works fine after I revise the url to _knn_search.

Am I doing something wrong on the syntax? If not, hopefully we can add knn_search to dotnet client so that we don't have to write custom dotnet client.

If you are using the latest version of Elasticsearcg, it based on the docs looks like knn search uses the _search endpoint. Earlier it seems _knn_search was required.

Hi, @Jiaxiang_Wang.

As the knn_search endpoint is deprecated, we don't generate methods for calling that in the 8.0 client. This looks like it may be a bug. Can you open an issue for this? If you can capture the DebugInformation to access and share the serialized request, we can work out if this is an issue in the spec, code-gen or elsewhere.

Hi Steve. I truly appreciate your response to this issue. I just created an issue based on information I have and looking forward to hearing from you. Dotnet Client(`Elastic.Clients.Elasticsearch`) 8.0.1 doesn’t support knn_search · Issue #7054 · elastic/elasticsearch-net · GitHub

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.