Comments (9)
Can you send me your query and the results? Set Pretty(true).Debug(true)
in the SearchService
and paste the output (like here)?
from elastic.
Query:
{"aggregations":{"g_TargetUserName":{"aggregations":{"g_eventlog_id":{"aggregations":{"ts":{"date_histogram":{"field":"@timestamp","interval":"1m"}}},"terms":{"field":"TargetUserName"}}},"terms":{"field":"eventlog_id"}}},"query":{"range":{"@timestamp":{"from":"2015-01-08T15:54:50.750119001Z","include_lower":true,"include_upper":true,"to":"2015-01-08T16:04:50.750119001Z"}}}}
(Also side bug, Query output in debug doesn't pretty format (although I care more about having access to the rawquery in code anyways).
Head of Response, note the Keys are Ints of some sort (not quoted).
"aggregations" : {
"g_TargetUserName" : {
"doc_count_error_upper_bound" : 2,
"sum_other_doc_count" : 2487,
"buckets" : [ {
"key" : 5447,
"doc_count" : 2448,
"g_eventlog_id" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ ]
}
}, {
"key" : 16,
"doc_count" : 984,
"g_eventlog_id" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ ]
}
}, {
"key" : 4624,
"doc_count" : 829,
"g_eventlog_id" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 141,
"buckets" : [ {
"key" : "system",
"doc_count" : 194,
"ts" : {
"buckets" : [ {
"key_as_string" : "2015-01-08T15:54:00.000Z",
from elastic.
Can you update and try again? Should be fixed with this commit. Reopen if necessary.
from elastic.
I don't think this is going to be correct, since the key can be a number or a string (possibly other things)...
from elastic.
And in the tests, the key is indeed a string for e.g. the "users" aggregation.
from elastic.
So probably an interface, and then the user has to type switch I imagine? I had another idea but can't remember now...
from elastic.
We could to that as well. And you're right in that it's better because Keys can be of any type, not only strings and numbers.
However, remember that you'll then get a float64
when decoding the "Key" in your example. A type switch is not enough.
from elastic.
Maybe we could have the best of both worlds with this.
type AggregationBucketKeyItem struct {
Aggregations
Key interface{}
KeyNumber json.Number
DocCount int64
}
You could use Key
to get to the interface{}
while still having KeyNumber
for convenience.
if bucket.Key != float64(0) {
t.Errorf("expected %v; got: %v", float64(0), bucket.Key)
}
if got, err := bucket.KeyNumber.Int64(); err != nil {
t.Errorf("expected %d; got: %v", 0, bucket.Key)
} else if got != 0 {
t.Errorf("expected %d; got: %d", 0, got)
}
if bucket.KeyNumber != "0" {
t.Errorf("expected %q; got: %q", "0", bucket.KeyNumber)
}
from elastic.
See this test for example usage.
Hope this is going to fix it.
Thanks for reporting.
from elastic.
Related Issues (20)
- I want to get the result body. Is there any way? HOT 1
- Generating nested histogram query HOT 1
- The es daterange query data has no expected effect
- how to get root cause with 400 error HOT 1
- ()elastic.Each Swallowed the error
- Unresolved reference 'Aggregation, Size, TrackTotalHits, Pretty, Sort, and Do'
- Append support max_concurrent_shard_requests in msearch
- Support for Version=0 in bulk_delete_request.go HOT 2
- The collapse query does not support multiple inner_hit conditions HOT 1
- elastic v6 not work correctly with http proxy
- elastic: Error 400 (Bad Request): only write ops with an op_type of create are allowed in data streams [type=illegal_argument_exception]
- Can't use REST compatibility headers
- The context field in the structure SearchSuggestionOption(in search.go) should change to be highlight
- How to search data with a 'knn query'?
- the return value of add document
- Issue with Elasticsearch Alias Removal and Addition
- cannot unmarshal object into Go struct field ProductHits.hits.total of type int
- EasyJson compatibility issue
- search without retry when es return io.EOF
- How can I use Offset in date_histogram of composite aggregation?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elastic.