What is your python client version? The search body looks OK at first glance. Maybe the python client is doing something unexpected, I know in later versions of the client, you specify each part of the search body instead of the whole thing.
Thank you for great idea to try. Really appreciate. For some reason even with your excellent suggestion, I still get the same:
'parsing_exception', 'reason': 'Unknown key for a START_OBJECT in [knn].', 'line': 1, 'col': 8}
I wonder what "unknown key" really means... those dict key names like "field" and "query_vector" are taken from their own example, in the documentation.
RabBit_BR, you seem to be the only person in the known universe who's ever actually run this. Even the ES support people don't have an answer.
Could I trouble you to show me exactly how you called with that query? Did you use request/curl or straight python or how exactly did you get that to parse??
Client: Elastic.Clients.Elasticsearch 8.0.1
Elasticsearch DB version: 8
How I made request in C# Code:
var response = await _client.SearchAsync<ImageSearchDocument>(
s => s
.Knn(k => k
.QueryVector(embedding_vector) // ICollection<double>
.Field(_EmbeddingVectorStr) // string
.k(searchTotal) // long
.NumCandidates(numCandidate) // long
)
.SourceExcludes(_EmbeddingVectorStr) // string
.Index(FullImageSearchIndexName) //string
);
{"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}
This issue has confused me for 2 days. Any hints will be appreciated.
FIrst thing, I believe you better upgrade your deployment (on dashboard)
to 8.5.2 of the core Elasticsearch service ( and separately, make sure your client is the matching latest version, e.g. for me with Python that is 8.5)
Thank you for your reply. I double check that my ES is 8.3.2 and my es dotnet client(Elastic.Clients.Elasticsearch) is the last stable version 8.0.1
The Postman request successfully receive response with provided Request Body. Still trying to figure out why it doesn't work.
@Scott_M I think the issue in your case is that you are using search. What I suggest is to use knn_search instead of it.
Below Python code works for me:
target_float_list = [...]// a list of 256 floating number
res = client.knn_search(
index=client._active_index, knn={"field": "embedding_vector", "query_vector": target_float_list, "k": 10, "num_candidates": 100})
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.