There is C# code that generates searches through code like that: searchResult = client.Search(descriptor);
The request generated contains inappropriate data, and therefore I get Elasticsearch.Net.ElasticsearchClientException, and it's completely OK. When I turn on DisableDirectStreaming, I can see the json that ElasticsearchCluster returns and the root_cause in my apiCallDetails: "reason" : "[simple_query_string] analyzer [custom_search_analyzer] not found",
The problem is that I can not turn on DisableDirectStreaming due to perfomance cost and that searchResult is null, though the documentation on ElasticsearchClientExceptionExceptions | Elasticsearch.Net and NEST: the .NET clients [6.x] | Elastic states that the response should contain ServerError with the root cause.
What am I doing wrong here? How can I tune the code or the elasticsearch cluster to get from client.Search not-null response with ServerError and the root cause?
Hi Carly, thank you for changing the tag, it's got really more correct, here are my sting of code and some additional explainaition:
// Client generation
var settings = new ConnectionSettings(connectionPool)
.DisableDirectStreaming(false)
.ThrowExceptions(true)
.// and some more settings which are not importaint here
return new ElasticClient(settings);
and
// The search that I need to deal with:
var searchResult = await ReadClient?.SearchAsync(descriptor);
My goal is to get the root_cause for failed searchesfor example "reason" : "[simple_query_string] analyzer [custom_search_analyzer] not found",
How can I do it?
I would like neither setting DisableDirectStreaming(true) (due to performance reasons), nor 'ThrowExceptions(true)` (because for most searches with the same client we do need the exception).
So the desirable code is something like this:
var searchResult = await ReadClient?.SearchAsync(descriptor.MyTrickyWayToGetNotNullResponseEvenForFailedRequestsThoughThrowExceptionsIsSwitchedOn());
or some tricky way to get the root cause in .OnRequestCompleted() though DisableDirectStreaming is set to false.
Is it possible without creating different slients wit different ThrowExceptions behaviour?
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.