Collapse is not working Discover-Kibana

My Requirement : Display latest entry (createdAt field) corresponding to a "trade.execID" in Kibana Discover. When I trigger this query from dev tools, getting expected result (single record) but when trying to use same on in DSL query in Kibana Discover, it's returning all entries instead to latest one. I believe collapse is not working. Please suggest how to address it?

GET /iowa-activity/_search
{
"query": {
"match": {
"trade.execID": "501d78b8ab01"
}
},
"collapse": {
"field": "trade.execID.keyword"
},
"sort": [ {
"createdAt": {
"order": "desc"
}
} ],
"size": 1

}

Discover defaults to retrieving the first 500 documents that match your query. If you want to display the latest hit, you might try using the "top hits" aggregation in visualize, or changing the discover sample size in your advanced settings.

Thanks Lukas for reply. My query will not be based on any specify trade.execID. I mentioned it just for example. There will be no query section in my search. I want unique entry for each trade.execID. So I believe change size settings will not resolve my problem.

How Can I use top hit aggregation in Visualize? I need to show all fields corresponding to any unique trade.execID.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.