# Javascript, where's my output?

**URL:** <https://discuss.elastic.co/t/javascript-wheres-my-output/36470>\
**Category:** Elasticsearch\
**Created:** [December 6, 2015, 2:45pm UTC](https://discuss.elastic.co/t/javascript-wheres-my-output/36470 "2015-12-06T14:45:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scaarup](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scaarup/32/4615_2.png) [@scaarup](https://discuss.elastic.co/u/scaarup)\
**Post date:** [December 6, 2015, 2:45pm UTC](https://discuss.elastic.co/t/javascript-wheres-my-output/36470/1 "2015-12-06T14:45:37Z")

</div>

Hi guys.

Trying to do some searching via javascript to which I'm pretty noob. But I have this request done via curl:

> user@localhost /tmp $ curl -XGET 192.168.20.145:9500/\_search?pretty -d'  
> { "size": 0,"query": {"filtered": {"query": {"query\_string": {"query": "event:"Capture"","analyze\_wildcard": true}},"filter": {"bool": {"must": [{  
> "range": {  
> "@timestamp": {  
> "gte": 1448146800000,  
> "lte": 1448751599999,  
> "format": "epoch\_millis"  
> }  
> }  
> }  
> ],  
> "must\_not":   
> }  
> }  
> }  
> },  
> "aggs": {  
> "2": {  
> "date\_histogram": {  
> "field": "@timestamp",  
> "interval": "1d",  
> "time\_zone": "Europe/Berlin",  
> "min\_doc\_count": 1,  
> "extended\_bounds": {  
> "min": 1448146800000,  
> "max": 1448751599999  
> }  
> }  
> }  
> }  
> }'  
> {  
> "took" : 34489,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 281,  
> "successful" : 281,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 3877723,  
> "max\_score" : 0.0,  
> "hits" :   
> },  
> "aggregations" : {  
> "2" : {  
> "buckets" : [ {  
> "key\_as\_string" : "2015-11-22T00:00:00.000+01:00",  
> "key" : 1448146800000,  
> "doc\_count" : 462396  
> }, {  
> "key\_as\_string" : "2015-11-23T00:00:00.000+01:00",  
> "key" : 1448233200000,  
> "doc\_count" : 621186  
> }, {  
> "key\_as\_string" : "2015-11-24T00:00:00.000+01:00",  
> "key" : 1448319600000,  
> "doc\_count" : 600470  
> }, {  
> "key\_as\_string" : "2015-11-25T00:00:00.000+01:00",  
> "key" : 1448406000000,  
> "doc\_count" : 613689  
> }, {  
> "key\_as\_string" : "2015-11-26T00:00:00.000+01:00",  
> "key" : 1448492400000,  
> "doc\_count" : 651160  
> }, {  
> "key\_as\_string" : "2015-11-27T00:00:00.000+01:00",  
> "key" : 1448578800000,  
> "doc\_count" : 446081  
> }, {  
> "key\_as\_string" : "2015-11-28T00:00:00.000+01:00",  
> "key" : 1448665200000,  
> "doc\_count" : 482741  
> } ]  
> }  
> }  
> }

Gives me some buckets as I want. Then I have the same search done via javascript in node-js:

> var elasticsearch = require('elasticsearch');  
> var client = new elasticsearch.Client({  
> host: '192.168.20.145:9500',  
> log: 'trace'  
> });
> 
> client.search({  
> "size": 0,"query": {"filtered": {"query": {"query\_string": {"query": "event:"Capture"","analyze\_wildcard": true}},"filter": {"bool": {"must": [{  
> "range": {  
> "@timestamp": {  
> "gte": 1448146800000,  
> "lte": 1448751599999,  
> "format": "epoch\_millis"  
> }  
> }  
> }  
> ],  
> "must\_not":   
> }  
> }  
> }  
> },  
> "aggs": {  
> "2": {  
> "date\_histogram": {  
> "field": "@timestamp",  
> "interval": "1d",  
> "time\_zone": "Europe/Berlin",  
> "min\_doc\_count": 1,  
> "extended\_bounds": {  
> "min": 1448146800000,  
> "max": 1448751599999  
> }  
> }  
> }  
> }  
> }).then(function (resp) {  
> var hits = resp.hits.hits;  
> }, function (err) {  
> console.trace(err.message);  
> });  
> Running that in node:  
> root@mgp-es-101 opt # node test2.js  
> Elasticsearch INFO: 2015-12-06T14:36:50Z  
> Adding connection to [http://192.168.20.145:9500/](http://192.168.20.145:9500/)

Elasticsearch DEBUG: 2015-12-06T14:36:50Z  
starting request { method: 'POST',  
path: '/\_search',  
query:  
{ size: 0,  
query: { filtered: [Object] },

var elasticsearch = require('elasticsearch');  
aggs: { '2': [Object] } } }

Elasticsearch TRACE: 2015-12-06T14:36:50Z  
-\> POST [http://192.168.20.145:9500/\_search?size=0&query=&aggs=](http://192.168.20.145:9500/_search?size=0&query=&aggs=)

\<- 200  
{  
"took": 4,  
"timed\_out": false,  
"\_shards": {  
"total": 281,  
"successful": 281,  
"failed": 0  
},  
"hits": {  
"total": 553273927,  
"max\_score": 0,  
"hits":   
}  
}

Where are my buckets?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:33pm UTC](https://discuss.elastic.co/t/javascript-wheres-my-output/36470/2 "2017-07-05T23:33:14Z")

</div>


