Request serializer in Nest c#


(Artem) #1

Hi!

I have problem with request serializer in c# Nest client.
I have index with field name "sides_count". I want to include only this field in search response. But when MultiSearch method is executed, the exception occured. The request, generated by nest is invalid:

{
  "size": 1,
  "source": {
    "includes": [
      "sides_count"
    ]
  },
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "_id": {
              "value": "780000000001070#10"
            }
          }
        }
      ]
    }
  }
}

Error in "source" keywrod. It must be "_source".

C# code:

DateTimeProvider dtProvider = new DateTimeProvider();
dtProvider.DeadTime(1, TimeSpan.FromSeconds(3d), TimeSpan.FromMinutes(1d));

StaticConnectionPool pool = new StaticConnectionPool(connectionString.Split(';').Select(node => new Uri(node)), true, dtProvider);
ConnectionSettings connSettings = new ConnectionSettings(pool);


connSettings.EnableDebugMode();
connSettings.PrettyJson(false);
connSettings.RequestTimeout(TimeSpan.FromMinutes(30d));
connSettings.DefaultFieldNameInferrer(StringUtils.ConvertToLowerDelimeted);
connSettings.ThrowExceptions();
connSettings.DisablePing();

ElasticClient client = new ElasticClient(connSettings);



ISearchRequest searchReques = new SearchRequest("my_index","my_type");
searchRequest.Query = my_query;
SourceFilter sourceFilter = new SourceFilter()
{
    Includes = new []{"sides_count"}
};
searchRequest.Source = sourceFilter;
searchRequest.Size = 1;

{
"version" : {
"number" : "6.4.0",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "595516e",
"build_date" : "2018-08-17T23:18:47.308994Z",
"build_snapshot" : false,
"lucene_version" : "7.4.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
}
}

Nest 6.3.1,
Newtonsoft.Json 11.0.2

Thanks!


(system) #2

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