Query Array by Position

We have a URL field split on / into a path array field.

We now want to query documents in Kibana which have "something as their first element.

The following query fails in Kibana: path[0]: something:

We do however have documents which could potentially match this search as we see with: path: something:

That is unfortunately not possible. Elasticsearch doesn't store the original order of these elements when indexing it, so you can't query for first (or any order) of element. If you are often requiring that query, you could either store the first element in a separate field, you you know, that you will need to query it often. You could also prefix all values by their path id, like 1_something, 2_otherlink2, etc. so that you can query for them (maybe also as a copy of this field).

Also if you have the original path as one keyword available you could use a wildcard query on it, to check if it starts with a specific path.

Cheers,
Tim

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