block-quote On this pagechevron-down
copy Copy chevron-down
Liquid chevron-right Filters find_exp Finds the first item in an array that matches a Liquid expression. Unlike find, which compares a property to a value, find_exp lets you write arbitrary conditions using the full Liquid expression syntax.
Copy {% assign expensive = products | find_exp: "product" , "product.price > 100" %}
{% log expensive . title %}
Copy {{ array | find_exp: item_name , expression }} Array of objects to search
Variable name for the current item inside the expression
Liquid expression that evaluates to truthy/falsy
Returns the first item for which the expression evaluates to a truthy value, or null if no item matches.
Find first product above a price threshold:
Copy {% assign expensive = products | find_exp: "p" , "p.price > 50" %}
{% if expensive %}
{% log "First expensive product: " | append : expensive . title %}
{% endif %} Find first order with a specific tag:
Copy {% assign vip_order = orders | find_exp: "order" , "order.tags contains 'VIP'" %}
{% log vip_order . name %} Find first out-of-stock variant:
Find first item matching multiple conditions:
The item_name parameter defines how you reference each item inside the expression
The expression supports all Liquid operators: ==, !=, >, <, >=, <=, contains, and, or
Returns the first matching item only
For simple property-to-value comparisons, find is more concise
See also: where_exp (returns all matching items, not just the first)