When I send it directly to ElasticSearch the result contains an array aggregations['CompanyName.raw']['buckets'].
However, when I issue the same request with NEST this array is empty.
using (MemoryStream ms = new MemoryStream())
{
Client.RequestResponseSerializer.Serialize<ISearchResponse<ProductPurchasing>>(r, ms);
ms.Position = 0;
using (StreamReader sr = new StreamReader(ms))
{
string responseJson = sr.ReadToEnd();
}
}
Responses are not guaranteed to be re-serializable back to a MemoryStream or byte array. If you want to have both the response bytes and an instance of a response type to work with, you can either
Set .DisableDirectStreaming() either on ConnectionSettings to globally apply, or on an individual request, to buffer the request/response bytes on the response instance, in the . ApiCall.RequestBodyBytes or .ApiCall.ResponseBodyBytes, respectively.
or
Use the low level client to make the request, and return a StringResponse or BytesResponse. Then deserialize this response to a SearchResponse<ProductPurchasing>. If you use the low level client exposed on NEST through the .LowLevel property, you can pass a high level request like SearchRequest<ProductPurchasing> to the low level client using PostData.Serializable(request)
Thank you.
Using the low level client has got me what I need.
(We run a multi-tenant sytem so I'm intercepting queries written by ReactiveSearch to add various restrictions and exclude other clients' data such as prices. Using NEST to handle the queies ought to be easier than manipulating raw JSON and NDJSON.)
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.