Terms Aggregation KeyAsString is always null
See original GitHub issueNEST/Elasticsearch.Net version:2.4.6
Elasticsearch version: “version” : { “number” : “2.4.1”, “build_hash” : “c67dc32e24162035d18d6fe1e952c4cbcbe79d16”, “build_timestamp” : “2016-09-27T18:57:55Z”, “build_snapshot” : false, “lucene_version” : “5.5.2” },
Description of the problem including expected versus actual behavior:
Steps to reproduce:
- run Search with Terms aggregation on one of the object properties of type Guid
for example object like : {name: ‘SOME NAME’ guidVal: ‘034a7b09-9fee-4f63-a87f-4592edd9560d’}
var aggResponse = client.Search<TestClass>(s=>
s.Aggregations(a => a.Terms("distinc_bus", ad => ad.Field(t => t.guidVal))));
List<Guid> listOfGuids = aggResponse.Aggs.Terms("distinc_bus").Buckets.Select(b => Guid.Parse(b.Key)).ToList(); //this line will throw as key is not returned as valid Guid
- expected result : you get bucket that the bucket key ,or at least the KeyAsString is the same as the guidVal (i.e. ‘034a7b09-9fee-4f63-a87f-4592edd9560d’).
- actual result : the bucket key is only the last token of the Guid : “4592edd9560d”, and the KeyAsString is null (the value returned fine when reading a single document with Get() or multiple with Search() with no aggregations , so it is saved fine on the Elastic search itself)
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
KeyAsString is null using aggregations - Elasticsearch
Hi, I'm using Elastic 6.0.0. Using aggregations for the first time and I'm having some trouble with it. My documents look something like ......
Read more >Elasticsearch terms aggregation returns no buckets
New elasticsearch user here and having an issue with a terms aggregation. I have indexed 187 documents with fields like "name","host","risk" ...
Read more >Elastic - Go Packages
type Aggregation interface { // Source returns a JSON-serializable aggregation that is a fragment // of the request sent to Elasticsearch.
Read more >Bucket Aggregations - Open Distro Documentation
The terms aggregation returns the top unique terms. So, if the data has many unique terms, then some of them might not appear...
Read more >Elasticsearch - A Complete Guide - StudyLib
One should be careful while configuring default values for null. The default value should always be of the type corresponding to the data...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
if look at the mapping for this type,
yourindex/_mapping
you need to add the index setting. This is very good practice to use non-analyzed fields for terms aggregations.
On Sat, Nov 19, 2016 at 11:15 AM, Amir Sasson notifications@github.com wrote:
Doug Nelson
Meant to add that
.KeyAsString
maps to the value returned by Elasticsearch in the"key_as_string"
property of a bucket; for some keys such as dates, Elasticsearch returns a"key_as_string"
property as well as the numerical epoch time as the key. In NEST, we always read the"key"
as astring
, but #2336 is an issue to look at supporting any returned json value.