I am trying to execute a search query with search_type of count with the elasticsearch.angular.js build from the npm module.
I can execute the query like this:
POST /index1/type1/_search?search_type=count
{
"aggs": {
"reviews": {
"nested": {
"path": "reviews"
}
}
}
}
but when I try to translate the query to the .js api, I get an error. My code looks like this:
var requestObject = {
index:'index1',
type:'type1',
searchType: 'count',
body: {
query:{
aggs: {
reviews: {
nested: {
path: "reviews"
}
}
}
}
};
esClient.search(requestObject)
The trace looks like this:
console.js:1 DEBUG: 2015-08-04T15:28:59Z
starting request { method: 'POST',
path: '/index1/type1/_search',
body: { aggs: { reviews: [Object] } },
query: { search_type: 'count' } }
That looks OK to an elasticsearch newbie, but the request completes with an error: ReferenceError: count is not defined.
What am I missing here please?
aggspart needs to be a direct child of thebodyelement, i.e. not nested inside thequeryelement. Can you make that change and try again to see if that makes any difference?esClient.search()?