Better way of displaying KNN results in Kibana?

I'm using the approximate kNN feature to index a vector for searching. With the previous exact kNN method I was able to craft a URL string for the script_score query, but I haven't been able to replicate that with the approximate kNN approach, I assume because it uses a top-level knn key instead of putting it under the query key.

The approach I've come up with, which does work, but isn't particularly nice is to manually create a saved search, with attributes.kibanaSavedObjectMeta.searchSourceJSON set to the quote-escaped JSON string I'd be sending to elastic. This appears to not work when opened, but inspecting the request reveals Kibana is adding on the default query of

"query": {
    "bool": {
      "must": [],
      "filter": [],
      "should": [],
      "must_not": []

Running the whole query through the search profiler reveals the kNN search is being performed, but its results are being merged with the above query which returns everything in the index.

I've managed to solve this by adding a query myself which is guaranteed to return 0 results (the _id field must not exist), which then causes only the kNN results to be returned.

I then tried to reverse this back into the RISON-encoded URL: (other props removed for space)


but the rnn property is completely ignored and it just performs the query. Is there any other way of doing this without having to create a saved search each time?

Hi @freddyh !
There is no support for it yet. Could you please create a Github issue? Thanks!