Hello! Tried solving this via an Elastic Support case, got nowhere ... hoping the community can help.
I have a working GET script that successfully retrieves a single document (from an entire index) that contains the max value of a numeric field (in this case, a daily closing price for a mutual fund). See script and response below.
Now I want to plot that value (50.86) as a static horizontal line in a Lens panel (or in TSVB) -- such that the value never changes, regardless of the time range selected by the user.
Can anyone show me how to use the Lens UI to accomplish this based on my (working) script? I assume I should use a "formula" -- but I can't find any posts, videos, screengrabs, etc. anywhere that depict how.
Thanks!
[ snip ]
Particulars...
-
Index:
wxmd
-
X-Axis/Time Field:
last_update
-
Field:
price_close
-
Term:
symbol
(target value:dodfx
)
Script...
GET /wxmd/_search?pretty
{
"query": { "bool": { "filter": [ { "term": { "symbol": "dodfx" } } ] } },
"size": 0,
"aggs":{ "max_price_close": { "top_hits": { "sort": [ { "price_close": { "order": "desc" } } ], "size": 1 } } }
}
Response...
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1080,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"max_price_close": {
"hits": {
"total": {
"value": 1080,
"relation": "eq"
},
"max_score": null,
"hits": [
{
"_index": "wxmd",
"_type": "_doc",
"_id": "VGJc8nkBH0ZppaLYUYbw",
"_score": null,
"_source": {
"price_close": "50.86",
"volume": "0",
"last_update": "2021-06-08 13:00",
"symbol": "DODFX"
},
"sort": [
50.86
]
}
]
}
}
}
}