Finding an item in an array with partial match in ArangoDB

Query

1
2
3
4
LET needle = "eedl"
LET haystack = ["needle", "in", "a", "haystack"]
RETURN haystack[** FILTER CONTAINS(CURRENT, needle)]
// Output: ["needle"]

Variant: Case-insensitive

1
2
3
4
LET needle = "EEDL"
LET haystack = ["needle", "in", "a", "haystack"]
RETURN haystack[** FILTER CONTAINS(LOWER(CURRENT), LOWER(needle))]
// Output: ["needle"]

References

  1. Array operators - Inline filter
  2. String functions - CONTAINS()
  3. String functions - LOWER()