Skip to content

Include array deserialization causes exception #2503

@Jafferwaffer

Description

@Jafferwaffer

NEST/Elasticsearch.Net version: (Originally tested on 2.4.5) 2.5.0

Elasticsearch version: 2.4.0

Description of the problem including expected versus actual behavior:
I am trying to deserialize my ES query which has an include field containing an array of strings. The
query is working in Kibana Sense but throws an exception when trying to deserialize. The error occurs when serializing the aggregations section.

Here is the query:

{
  "aggs": {
    "sizes": {
      "terms": {
        "field": "size",
        "size": 20,
        "include": [
          "35",
          "50",
          "70",
          "75",
          "100"
        ]
      }
    }
  }
}

Steps to reproduce:
1.

Elasticsearch.Net.IElasticsearchSerializer.Deserialize<SearchRequest>(new MemoryStream(Encoding.UTF8.GetBytes(query)))
  1. Exception is thrown.

Provide DebugInformation (if relevant):
Exception thrown:

  • An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user code
    Additional information: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Nest.TermsIncludeExclude' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions