Hi all:
Just getting started with ElasticSearch. I've taken some log4j output
and inserted it into ElasticSearch to give me some data to play with,
which looks like the following:
{
total: 34,
max_score: 1,
hits: [
{
_index: "tomcat",
_type: "base",
_id: "an_id",
_score: 1,
_source: {
loggerName: "stuff",
message: "stuff",
level: "stuff",
timestamp: "stuff",
thread: "stuff"
}
},
So, now I'm trying to actually query / sort this data. I'm building a
JSON request that looks like:
q = {
"from": offset,
"size": numItems,
"sort" : [
"level" : { "order" : "asc" }
],
"query" : {
"term" : { "level" : targetLevel }
}
}
And execute the request with:
$.getJSON(myUrl, q, function(rData) {
console.log(rData);
});
However, what I get back is an unordered list of every log item,
rather than the sorted list that I'm looking for.
I've also tried:
q = {
"from": offset,
"size": numItems,
"sort" : [
"level"
],
"query" : {
"term" : { "level" : targetLevel }
}
}
and a number of other variations, but haven't had much success.
Neither the search nor the sort seem to work.
I'm sure I must be making an obvious mistake. That said, if anyone
could point me in the right direction here, it would be greatly
appreciated
Also, related question: is there a simple way to ask ElasticSearch to
be verbose about how / why it's filtering and sorting its results?
Thanks all!
--