Search code examples
elasticsearchkibana

Multi-stage query


I want to see all results matching a particular Guid, as well as all results matching a particular field (fish_tag) from the first results, whether they have the Guid or not.

For example, in Stage 1 I search for eb23c255-2986-4bf5-8b99-dd123affe739, and say 20 results are returned. Of the 20, some have nothing in their fish_tag field, and some have values (not necessarily unique). In Stage 2 I search only the fish_tag field for all the values returned in Stage 1 and many more results are returned, say 100. Included in the Stage 2 results are the results from Stage 1 with the searched fish_tags.

Ideally I am looking for a one query to return the combination/concatenation of Stage 1 and Stage 2, or if that is not possible to return Stage 2 in one query.

Is it possible to craft such a multi-stage query in Kibana?


Solution

  • the Elastcsearch search query is one-pass. So there is no a way to search in results of previous search

    You can use the bool query (as @Musab Dogan adviced) and compose a condition:

    (GUID == 'eb23c255-2986-4bf5-8b99-dd123affe739') AND (fish_tag IS NOT empty)