Skip to content

Support for Elasticsearch 6.3 "missing" in Composite Aggregation #3540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hanswieheiri opened this issue Jan 10, 2019 · 6 comments
Closed

Support for Elasticsearch 6.3 "missing" in Composite Aggregation #3540

hanswieheiri opened this issue Jan 10, 2019 · 6 comments
Assignees

Comments

@hanswieheiri
Copy link

hanswieheiri commented Jan 10, 2019

NEST/Elasticsearch.Net version: 6.4.1

Elasticsearch version: 6.3.0

Description of the problem including expected versus actual behavior:
I am using ICompositeAggregationSource where the field missing_bucket was newly added (that's compatible with Elasticsearch version 6.4.0). In 6.3.0 that field was called missing.

Is there a way to force serialization that would serialize bool? MissingBucket { get; set; } as missing instead of missing_bucket.

Thanks for your help.

@russcam
Copy link
Contributor

russcam commented Jan 15, 2019

Relates elastic/elasticsearch#29465

missing and missing_bucket are not the same; the former allows to set an explicit value when the value is null, whilst the latter emits
an explicit null value for documents without a value for a field.

missing is deprecated and will be removed in 7.x. I'm not that keen on the idea of implementing an already deprecated feature. Thoughts @Mpdreamz, @codebrain ?

@hanswieheiri would sending a query with the low level client, and returning a high level response work in the meantime?

var searchResponse = client.LowLevel.Search<SearchResponse<MyDocument>>("index", "type",
    PostData.Serializable(new
    {
        aggs = new {
            my_buckets = new {
                composite = new {
                    sources = new[] {
                        new { 
                            product = new { 
                                terms = new { 
                                    field = "product",
                                    missing = "my_missing_value"
                                } 
                            } 
                        }
                    }
                }
            }
        }
    }));

which would serialize to

{
  "aggs": {
    "my_buckets": {
      "composite": {
        "sources": [
          {
            "product": {
              "terms": {
                "field": "product",
                "missing": "my_missing_value"
              }
            }
          }
        ]
      }
    }
  }
}

@hanswieheiri
Copy link
Author

hanswieheiri commented Jan 15, 2019

Hi @russcam I agree it's not quite the same. Using the low level client kind of makes sense but I have a complicated logic in my "query". I.e. I would have to rebuild a lot! Is it maybe possible to modify the JSON string before its sent to Elastic?

@Mpdreamz
Copy link
Member

I'm OK with adding missing given the alternative is to drop down to the low level client as long as #1016 is also still an open feature request.

@hanswieheiri
Copy link
Author

In the meantime I wrapped Elasticsearch.Net.SerializableData for modifying the json via string replace in the method Write(Stream writableStream, IConnectionConfigurationValues settings).

The wrapper I injected in DispatchAsync() (by inheriting from ElasticClient)

Ugly but it works for now.

@russcam
Copy link
Contributor

russcam commented Mar 7, 2019

We'll look to add this in for the 6.6.0 release @hanswieheiri

@russcam
Copy link
Contributor

russcam commented Mar 15, 2019

Closing this; will be in the next release, 6.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants