I'm experiencing a query parsing exception while utilizing JavaScript for Elasticsearch configuration found in elastic.js file.
Results are obtained when the filtered part is removed. However, upon adding it back, an exception occurs.
var client = require('./elastic.js');
client.search({
index: 'test-2017.03.25',
size: 0,
body: {
query: {
bool: {
must: {
match: {
status: 502,
}
},
},
filtered: {
query: {
range: {
timestamp: {'gt': 1490380200000}
}
}
}
}
}
}, function (error, response, status) {
if (error) {
console.log("search error: " + error)
}
else {
console.log("--- Response ---");
console.log(response);
console.log("--- Hits ---");
response.hits.hits.forEach(function (hit) {
console.log(hit);
})
}
});
This represents my object mappings:
"test-2017.03.02": {
"mappings": {
"log": {
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"@version": {
"type": "string"
},
"beat": {
"properties": {
"hostname": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"body_bytes_sent": {
"type": "string"
},
"count": {
"type": "long"
},
...
}
}
}
}
Data retrieval based on status and request with filtering through the timestamp field is what I aim for.
The current error received is:
search error: [parse_exception] failed to parse search source. expected field name but got [START_OBJECT]
Please assist.
Sample Document :
{
"_index": "test-2017.03.25",
"_type": "log",
"_id": "JI9u8hGG8y8gGUk",
"_score": 1.0,
...
}
}