In my Elasticsearch index I store multiple documents with fields like date, sequence etc. It looks like shown below. My goal is to find reordering. It means that I should sort all documents by date and check whether all sequence numbers are ordered by date. If some of them are reordered I write in chosen document field packet_reordered and the number of documents for which the package has been reordered based on the date. If document is ordered in a correct way I write the value 0 in the packet_reordered field. I tried to use scripted field however I have some problems when it comes to do operations on multiple documents using Painless.
Is it possible to use for example python instead of painless in scripted fields using Elasticsearch 7.4.2?
{
"took": 4632,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 130,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "logs",
"_type": "log",
"_id": "yrsas24BmxPy23WAM2TeeQ",
"_score": 1.0,
"_source": {
"name": "something23",
"date": "2019-11-26T01:30:40",
"sequence": 34
}
},
{
"_index": "logs",
"_type": "log",
"_id": "y7sas24BmxPy23WAM2TeeQ",
"_score": 1.0,
"_source": {
"name": "something",
"date": "2019-11-26T01:32:23",
"sequence": 23
}
},
...