Skip to content
Back

Substring lookup for array elements

  • 0
  • 2
  • Tools
  • Web
  • Cloud
Los Feliz
16 Feb, 2026, 23:59

Hello, Is substring look up possible for array of strings?

TypeScript
Query.contains('product_names', [chair]),

this only works if I have the exact item name. cha instead of chair does not work.

product_names is a an array: ['chair', 'door', 'table']

TL;DR
AppWrite may not support substring searches for array elements in the database. The `.contains()` method works for strings but not arrays.
17 Feb, 2026, 20:50

try .contains()

17 Feb, 2026, 20:51

product_name.contains('chair')

17 Feb, 2026, 20:51

I would cast your query results to a var with a type and then use your languages type functions to parse the list, not try to handle that with the Appwrite sdk

17 Feb, 2026, 20:52

my issue is, product_name.contains('chair') works, but product_name.contains('cha') does not fetch the rows that have chair as one of the array elements.

17 Feb, 2026, 20:52

it would also help to know what language you're using

17 Feb, 2026, 20:52

this js. for web

17 Feb, 2026, 20:54

Then I think we're confusing 2 things here, searching a list, and using the SDK to search for rows whose product contains characters. You might try Query.contains['product_name', searchTermVariable] and have that run onKeyUp https://appwrite.io/blog/post/introducing-new-database-operators but this will result in hecking calls to your DB

17 Feb, 2026, 20:55

If that doesn't work it's possible AppWrite doesn't support partial searches / substring searches in the DB

17 Feb, 2026, 20:55

but I'm not an expert I've been using appwrite for like a week

1
17 Feb, 2026, 20:58

.contains() does substring look up but when it is just a string, and not an array. so you are not wrong thinking about .contains().

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more