Hi,
I am trying to achieve a result set where if there are 10 records, I want only 9 of them. Excluding the one which has maximum id.
For instance, there are 4 docs in my index.
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 4,
"max_score" : 1.0,
"hits" : [
{
"_index" : "rank",
"_type" : "data",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"id" : 2,
"name" : "Rank2"
}
},
{
"_index" : "rank",
"_type" : "data",
"_id" : "4",
"_score" : 1.0,
"_source" : {
"id" : 4,
"name" : "Rank4"
}
},
{
"_index" : "rank",
"_type" : "data",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"id" : 1,
"name" : "Rank1"
}
},
{
"_index" : "rank",
"_type" : "data",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"id" : 3,
"name" : "Rank3"
}
}
]
}
}
Mapping as
{
"rank" : {
"mappings" : {
"data" : {
"properties" : {
"id" : {
"type" : "long"
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
I want to fetch only last 3 records.
A query something like
GET rank/_search
{
"from":1,
"query":{
"match_all": {}
},
"sort": [
{
"id": {
"order": "desc"
}
}
]
}
Since I am using from:1, it would exclude id:4. I needed the same results in Kibana Data Table. Kindly guide how should I proceed.
Thanks.