# Different data from Elastic search in dev tools and java script client

**URL:** <https://discuss.elastic.co/t/different-data-from-elastic-search-in-dev-tools-and-java-script-client/96887>\
**Category:** Elasticsearch\
**Created:** [August 13, 2017, 9:46pm UTC](https://discuss.elastic.co/t/different-data-from-elastic-search-in-dev-tools-and-java-script-client/96887 "2017-08-13T21:46:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![biood](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@biood](https://discuss.elastic.co/u/biood)\
**Post date:** [August 13, 2017, 9:46pm UTC](https://discuss.elastic.co/t/different-data-from-elastic-search-in-dev-tools-and-java-script-client/96887/1 "2017-08-13T21:46:51Z")

</div>

Hello,

I have the problem with query for elastic search from java script side.

Stack:  
Kibana 5.2.1  
Elasticsearch 5.2.1

First, I have created a query and test it in kibana dev tools.  
The query works correct and returns data which are interesting for me.  
Next I try to do the same on java script side with callWithRequest method, but unfortunately, I don't have the same results.  
For example in Kibana dev tools i have for first aggregation **byFinished** return **doc\_count = 144** which is correct and in JS return **doc\_count = 734**

**Query in dev tools** :  
"\_source": ["uniqueId","eventType","date","eventOutcome"],  
"query": {  
"bool": {  
"must": [  
{"match" : {"eventType": "Finishing"}}  
]  
}  
},  
"aggs": {  
"byFinished": {  
"filter": {"term": {  
"eventType.keyword": "Finishing"  
}},  
"aggs": {  
"byUniqueId": {  
"terms": {"field": "uniqueId.keyword",  
"size": 500  
},  
"aggs": {  
"byDate": {  
"date\_range": {  
"field": "date",  
"format": "yyyy-MM-dd'T'HH:mm",  
"ranges": [  
{  
"key": "lastHour",  
"from": "2017-08-10T08:00",  
"to": "2017-08-10T9:00"  
},  
{  
"key": "lastSixHours",  
"from": "2017-08-10T08:00",  
"to": "2017-08-10T15:00"  
},  
{  
"key": "today",  
"from": "2017-08-10T00:00",  
"to": "2017-08-11T00:00"  
}  
]  
},  
"aggs": {  
"byEventOutcome": {  
"terms": {  
"field": "eventOutcome.keyword"  
}  
}  
}  
}  
}  
}  
}  
}  
}

**Query in JS**  
handler(req,reply){  
callWithRequest(req, 'search', {  
from: 0,  
size: 1000,  
body: {  
\_source: ['uniqueId','eventType','date','eventOutcome'],  
query: {  
bool: {  
must: [  
{match : {'eventType': 'Finishing'}}  
]  
}  
},  
aggs: {  
byFinished: {  
filter: {term: {  
'eventType.keyword': 'Finishing pipeline'  
}},  
aggs: {  
byUniqueId: {  
terms: {field: 'uniqueId.keyword',  
size: 500  
},  
aggs: {  
byDate: {  
date\_range: {  
field: 'date',  
format: "yyyy-MM-dd'T'HH:mm",  
ranges: [  
{  
key: 'lastHour',  
from: '2017-08-10T08:00',  
to: '2017-08-10T9:00'  
},  
{  
key: 'lastSixHours',  
from: '2017-08-10T08:00',  
to: '2017-08-10T15:00'  
},  
{  
key: 'today',  
from : '2017-08-10T00:00',  
to: '2017-08-11T00:00'  
}  
]  
},  
aggs: {  
byEventOutcome: {  
terms: {  
field: 'eventOutcome.keyword'  
}  
}  
}  
}  
}  
}  
}  
}  
}  
},  
index: 'myIndex',  
type: 'myType'  
}).then(function(response){  
reply(response);  
});

Best regards

---

<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:** [September 10, 2017, 9:47pm UTC](https://discuss.elastic.co/t/different-data-from-elastic-search-in-dev-tools-and-java-script-client/96887/2 "2017-09-10T21:47:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
