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

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

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