I am trying to implement a simple query in Kibana and then in C# NEST. I am from a SQL background and am struggling to find documentation to perform a relatively simple SQL query in Elasticsearch. The query I am trying to implement is effectively......
SELECT * FROM table
WHERE logdate > STR_TO_DATE('2020-02-01 23:59:59','%Y-%m-%d %H:%i:%s')
AND logdate < STR_TO_DATE('2020-02-03 00:00:00','%Y-%m-%d %H:%i:%s')
AND username = 'user01'
I can do them as individual kibana queries....
GET table/_search
{
"query": {
"range": {
"logdate": {
"gt": "2020-02-01T23:59:59",
"lt": "2020-02-03T00:00:00"
}
}
}
}
GET table/_search
{
"query": {
"match": {
"username": "user01"
}
}
}
But when I try and combine them into one query I get a "parsing_exception" error...
GET table/_search
{
"query" : {
"bool" : {
"must": [
{
"match": {
"username": "user01"
},
"range": {
"logdate": {
"gt": "2020-02-01T23:59:59",
"lt": "2020-02-03T00:00:00"
}
}
}
]
}
}
}
I have looked at the Elasticsearch documentation and can't seem to find the answer so any help would be appreciated, thanks in advance