First we index the numbers from 1 to 10 using json_lines and cryptocli in a temporary index.
seq 1 10 | \
bash json_lines.sh number 1 2>/dev/null | \
./cryptocli \
-- stdin \
-- line \
-- elasticsearch-put \
--index number_messages \
--type number \
--raw
Then, for each messages in the last 15 minutes in the temporary index, we deserialize the message field from json, set the right index to our final number index, set the right fields.type.
Finally, we extract the number from the json_line and set it to the root of the source.
cryptocli \
-- elasticsearch-get \
--index number_messages \
-- fork jq -rnc '
inputs |
._source.json_lines = (._source.message | fromjson) |
del(._source.message) |
._index = "number" |
._source.fields.type = ["json_lines", "number"] |
select(._source.json_lines.status == "stopped") // ._source.number = (._source.json_lines.lines[0].line | tonumber) |
del(._source.json_lines.lines[0].line)' \
-- elasticsearch-put