Filtering by a Field in an Array
TLDR Andrew asked how to filter by a field in an array. Jason provided the solution animals:[cat]
and a documentation link.
Powered by Struct AI
4
7mo
Solved
Feb 19, 2023 (7 months ago)
Andrew
Andrew
05:02 PMCan i filter by a field being in an array? For instance,
String animal = ‘cat’;
List<dynamic> animals = [dog, cat, fish,]
Filter by: animals:contains[cat]
Just pseudo code but i hope the point makes sense
String animal = ‘cat’;
List<dynamic> animals = [dog, cat, fish,]
Filter by: animals:contains[cat]
Just pseudo code but i hope the point makes sense
Jason
Jason
05:05 PMYup. You want to do
animals:[cat]
05:05
Jason
05:05 PMDocumented under
filter_by
: https://typesense.org/docs/0.24.0/api/search.html#filter-parameters05:05
Jason
05:05 PMSearch for “Filtering Arrays”
Typesense
Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI
Indexed 2776 threads (79% resolved)
Similar Threads
Filtering Out Fields Using Array Parameter
Andrew asked how to filter fields based on an array parameter. Jason offered a solution, which Andrew found helpful.
4
11mo
Solved
Usage and Modification of Dynamic Routes in Typesense Documents
Ethan needed a way to perform exact queries through two fields in Typesense documents. Kishore Nallan demonstrated its possibility using the "filter_by". An issue was resolved via recommending that fields in 'query by' should be a string type.
26
9mo
Solved
Array Object Fields Filtering in Typesense
Sathya asked about filtering array object fields, with Kishore Nallan replying that Typesense requires fields to be indexed in a flattened form before queries can be made.
2
20mo
Solved