I am wanting to not only surface my content in the system-level Spotlight search results but also to utilize the same index for my in-app search screen. The very few examples or tutorials I could find all craft a CSSearchQuery
string using just the "title" attribute. I can't figure out where to look to understand how to search across other attributes.
My most pressing need is to be able to perform a CSSearchQuery
looking for a search term in the .htmlContentData
attribute. If I search for this term in the system search field it returns results, so I know it's being indexed. However when I use a search query (in my app) like htmlContentData == "someSearchTerm"
I get zero results.
This frustration has led to some more general questions like:
How do you know what attribute names are available to use in the search query? Is it just a string literal that's exactly the same as the CSSearchableItemAttributeSet
property in Swift? e.g. property .htmlContentData
is referred to as "htmlContentData" in the query string?
Also, is there any way to just search across all attributes with CSSearchQuery
? Obviously using the system Spotlight search (from Home Screen) you don't have to specify if you're searching the title or htmlContentData, it just finds it in either. Yet for CSSearchQuery
I have to know up-front which fields I want to look in?