Get surrounding documents via API

Hello!

Is there any way to replicate "Surrounding Documents" function from Kibana but via API?

I'm trying different ways, but none is working (span_near, scroll API...).

Any help is appreciated!

Any solution?

May be a better luck is by asking in #kibana channel how the team implemented that or read Kibana source code?

1 Like

Thanks, moved to Kibana forum.

2 searches (maybe delivered in a single msearch) - one for dates greater than focal point, sorted ascending and the other less than or equal to focal point sorted in descending date order. Stitch them together in the client?

Yes, its a possibility, but I don't have a "focal point". My query retrieves a variable number of results, and I want this results and, for example, 20 next surrounding documents, like "grep -A 20" from Linux.

So you'd have a variable number of focal points each of which require querying in this way.

Note that grep on a local file has a significant advantage over search on a distributed system when it comes to this task.