what i am doing now is get all data and filter the "day of Month" like 2020-01-05, 2020-02-05
in pandas,
how can i search specific Day of Month in Elasticsearch?
my doc is something like below
{
"took": 80,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1508,
"relation": "eq"
},
"max_score": null,
"hits": [
{
"_index": "test_data",
"_type": "test",
"_id": "SlR42nYBlaUrIoJsVOv6",
"_score": null,
"_source": {
"timestamp": 1609983082524,
"timestampstring": "2021-01-07 09:31:22.524",
"oneNetDevieId": "624232444",
"type": "data"
},
"sort": [
2609983082524
]
},
{
"_index": "test_data",
"_type": "test",
"_id": "6FRL2nYBlaUrIoJsAuba",
"_score": null,
"_source": {
...
I have try something like
{
"query": {
"filtered": {
"filter": {
"script": {
"script": "doc.timestampstring.date.dayOfMonth == 5"
}
}
}
}
}
or
{
"query": {
"filtered": {
"filter": {
"script": {
"script": "doc._source.timestampstring.date.dayOfMonth == 5"
}
}
}
}
}
and it shows error
"type": "parsing_exception",
"reason": "unknown query [filtered]",
"line": 5,
"col": 17
or do i need to mapping?thanks
Edited update:
i got the new error:
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"doc['timestamp'].value.getDayOfMonth() == 5",
" ^---- HERE"
],
"script": "doc['timestamp'].value.getDayOfMonth() == 5",
"lang": "painless",
"position": {
"offset": 22,
"start": 0,
"end": 43
},
"caused_by": {
"type": "illegal_argument_exception",
"reason": "dynamic method [java.lang.Long, getDayOfMonth/0] not found"
}
}
}
]