Hi,
I would like to create a visualization in Kibana on the top-k relevant documents based on _score. I am able to retrieve exactly what I want in Discover (See picture). However, I have tried to create something similar in a Data Table with the Top Hits aggregation, but I am not sure how to set it up properly and I am not getting the result I need.
I have created a Query to calculate the score:
{
"aggs": {
"top_k": {
"aggs": {
"max_score": {
"max": {
"script": "_score"
}
},
"top_hit": {
"top_hits": {
"size": 1
}
}
},
"terms": {
"field": "message.keyword",
"order": {
"max_score": "desc"
},
"size": 10
}
}
},
"query": {
"function_score": {
"functions": [
{
"gauss": {
"createdAt": {
"origin": "now",
"scale": "1h"
}
}
}
],
"query": {
"bool": {
"minimum_should_match": 1,
"should": [
{
"match_phrase": {
"message": "Trump"
}
},
{
"match_phrase": {
"message": "America"
}
},
{
"match_phrase": {
"message": "President"
}
}
]
}
}
}
}
}
Is it possible to create a visualization that gives me a list over the top-k most relevant documents based on the query?
Thanks in advance!