I have a collection of Bar
s, each of which have isar links to Foo
s:
@collection
class Bar{
Id? id;
final foos = IsarLinks<Foo>();
... // Bar stuff
};
Each Foo
object has a field named text
, which is a String
:
@collection
class Foo{
Id? id;
late String text;
... // Foo stuff
};
Now, what I would like to do is search and find all the Foo
s linked to a particular Bar
that contain all of the given key words in their text
(preferably case insensitive). So, searching with the key words "canada" and "street" should match a Foo
with text = "I don't know what street, Canada is on. - Al Capone
Isar has a guide on how to do a full text search. In it, they recommend adding an index of the words of the text searched on, like so:
@collection
class Foo{
Id? id;
late String text;
@Index(type: IndexType.value, caseSensitive: false) // for more flexibility; see https://isar.dev/recipes/full_text_search.html#i-want-more-control
List<String> get words => Isar.splitWords(text); // see https://isar.dev/recipes/full_text_search.html#splitting-text-the-right-way
};
However, there does not seem to be an easy way to filer based on an index with IsarLinks
.
My questions:
- Is there a way to filter based on an index through all the items of an
IsarLinks
object? - If not, what would be the best way to perform a text search like I described? As a bonus question, why can't I do this with
IsarLinks
?
Note: I know I can simply use IsarLinks.filter
and build a query that selects all Foo
s with text
containing all the key words, but I am wondering if there is a way to do a text search in the way Isar
(with indexes) recommends on IsarLinks
.