-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypedKeys property not working - always return true #8431
Comments
Example Query: |
Hi @bsehrabt, typed-keys are forced to `true´ by the client. This is required to correctly deserialize the response (otherwise the client would not know what type of aggregation was returned by the server). May I ask why this is a concern? The client as well removes the prefix internally so that you can still access the aggregations by the name you provided: request.Aggregations.GetCardinality("my_agg_name") |
Hi @flobernd , Thanks for your reply. Actually we have a custom method which processes the search response. Example showing accessing json response both with TypedKeys(false):
Also we can no longer access filters aggs with keys in v8, there is an open bug for this -> #8242 and we are making use of index for now as a workaround. |
Hi @bsehrabt,
This would completely break deserialization of the response and cause an exception. I'm very sorry, but you are using the client in a very non-standard way. Accessing the raw JSON response by using The intended way of performing low-level requests, is using the transport layer directly. Read more about this here. If you don't want to manually craft the request, I would suggest something like this: var searchRequest = new SearchRequest("my-index-000001")
{
From = 0,
Size = 10,
Aggregations = new Dictionary<string, Aggregation>
{
{ "my_agg", Aggregation.Cardinality(new CardinalityAggregation{ Field = "my_field" })}
}
};
var myJsonRequest = client.RequestResponseSerializer.SerializeToString(searchRequest);
var path = new EndpointPath(HttpMethod.GET, "/my-index-000001/_search?filter_path=aggregations&typed_keys=false"); // Or better: Completely omit 'typed_keys' from the query portion of the url.
var myJsonResponse = client.Transport.RequestAsync<StringResponse>(path, PostData.String(myJsonRequest), null, null, default); Please note, that only the body properties are serialized this way. Some parameters must be configured in the path (e.g. the index name in this case) and others in the query portion of the url (like e.g. |
Elastic.Clients.Elasticsearch version: 8.15.8 / 8.16.3
Elasticsearch version: 8.13.4
.NET runtime version: 8.0
Operating system version: Win 11
Description of the problem including expected versus actual behavior:
A clear and concise description of what the bug is.
TypedKeys property is not honored and always returns true.
Steps to reproduce:
Expected behavior
A clear and concise description of what you expected to happen.
SearchAsync should return search results with typed_keys false
Provide
ConnectionSettings
(if relevant):Provide
DebugInformation
(if relevant):The text was updated successfully, but these errors were encountered: