I’m using swift 4, Xcode 9, iOS 11
I am continuing to learn about CoreData via tutorials and Q&A posts, but I can’t seem to figure out how to answer this question.
I have a CoreData entity with one attribute and 12 relationships to different entities that each contain 1-3 attributes. This is because any given object within the main entity can have multiple additional details within each related entity.
I would like for the user to be able to search and match nearly anything within the database. My current attempt loops through the main entity with a FetchRequest and within each loop matches relationships. This works but is (as expected) somewhat slow.
I tried using a predicate laid out something like this: “name contains TERM OR ANY relation.name contains TERM......” But this grew into a long predicate and took 30+ seconds to load per fetchrequest. Much slower than without a predicate.
How do I essentially search the entire database more efficiently? Is there a better way to write the predicate? Is there a better way to design my data model?
Thank you for any guidance.