Skip to content

KeyNumber.String() broke for go 1.14 #1304

@rbUUbr

Description

@rbUUbr

Please use the following questions as a guideline to help me answer
your issue/question without further inquiry. Thank you.

Which version of Elastic are you using?

[x] elastic.v7 (for Elasticsearch 7.x)
[ ] elastic.v6 (for Elasticsearch 6.x)
[ ] elastic.v5 (for Elasticsearch 5.x)
[ ] elastic.v3 (for Elasticsearch 2.x)
[ ] elastic.v2 (for Elasticsearch 1.x)

Hi! Great library! I'm using nested aggregation together with terms aggregation. I've just upgraded go to 1.14 and find out that AggregationBucketKeyItem returns empty string for aggregated keys in KeyNumber field

Please describe the expected behavior

Get same data in KeyNumber field that I have in Key field

Please describe the actual behavior

I'm getting "" in KeyNumber field, but I have actual data in Key field

Any steps to reproduce the behavior?

aggregation function

	myAggregation := elastic.NewNestedAggregation().Path("tags").SubAggregation(
		"tags",
		elastic.NewTermsAggregation().Field("tags.name").Size(20))
	service := elastic.Client.
		Search().
		Index("tags").
		Aggregation("tags", myAggregation).
		Query(elastic.NewBoolQuery())

transformation function:

	aggregation, found := searchResult.Aggregations.Nested("tags")
	if found {
		tagsResult, found := aggregation.Terms("tags")
		if found {
			bucketsCount := len(tagsResult.Buckets)
			result := make([]*models.TagCompanyGroup, bucketsCount)
			for i, b := range tagsResult.Buckets {
				//key := b.Key.(string)
				result[i] = &models.MyCustomTag{
					Tag: &models.Tag{
						Slug: b.KeyNumber.String(), // doesn't work with go 1.14
					},
					Key:            b.KeyNumber.String(), // doesn't work with go 1.14
					Count: b.DocCount,
				}
			}
			return result, nil
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions