Skip to content

CompositeAggregationDescriptor.After() ignores null values in after_key #3575

@joostvz

Description

@joostvz

NEST/Elasticsearch.Net version: 6.5.0

Elasticsearch version: 6.5.4

Description of the problem including expected versus actual behavior:
I've created a composite aggregation query in the NEST client where I use 3 fields as key (let's call them x, y & z). These fields are missing in some of my documents, hence Elasticsearch returns the following after key:

"after_key" : {
  "x" : "Some value",
  "y" : null,
  "z" : null
}

The CompositeBucketAggregate.AfterKey property in the result contains a correct CompositeKey, with 3 keys and 3 values (2 of them are null). But when I add this CompositeKey to the next request via CompositeAggregationDescriptor.After(), the query it produces contains only 1 key:

"after": {
  "x": "Some value"
}

So the null values are missing in the request, and Elasticsearch will give me an error saying I didn't provide enough values for the key.

I guess this happens because of some default JSON serialization (where null values are not included in the JSON). Is there a way to override this behavior? Or is this a bug in the NEST client?

Metadata

Metadata

Assignees

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