Spotlight indexing for notes-like app

I was looking into the CoreSpotlight APIs and watched the WWDC 2015 talk (unfortuantely only half a session was devoted to this)... and I had a couple of questions how to best use the API:

- when you create a CSSearchableItemAttributeSet and add it to the index, what actually gets indexed? Just the titles, the content description as a whole, and/or each element of the description?

- if I have a notes-like app, where user enters in a description of an event, do we tokenize the notes field and create a separate item for each word-token, or can we add the whole notes passage into the content-desciption?


This would help think about how to implement the CoreSpotlight functionality into my app.

Thanks.

Good questions. I don't have a definitive list of which of the many attributes actually get indexed, I'll try to get some clarification around that.


You definitely would not want to do separate items for each word-token. What you'd want to do is have an item entry associated with each note (or whatever reasonably high level notion of a "document" that would make sense for your app). Presumably you'd put the contents of the note into the textContent property. In a quick test that appears to be getting indexed.

Accepted Answer

To follow up on this, all of the fields of CSSearchableItemAttributeSet get indexed, so whatever you put in there should be indexed. If you're not seeing something get indexed then you should file a bug report (preferably with a small test project exhibiting the incorrect behavior). Were there any attributes that you weren't seeing get indexed and be searchable?

No, I was just wondering before I started playing with it. Works just fine, as far as this is concerned.


A couple of other questions while you're here:

- with Core Spotlight index, is there a way to get it to display the phone/email/message icons within the spotlight results display? Or is that only possible with web markup?

- in the WWDC talk, they initialized the attribute set with an Image type :

CSSearchableItemAttributeSet* attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString *) kUTTypeImage];

What are the different types of "types" that one can specify here, and would it make a difference to the layout of the results?

- within CSSearchableItemAttributeSet, there seem to be different 'categories' specified for events, photos, documents etc. How are we supposed to use these?



Thanks for the help. There still doesn't seem to be much documentation available on Core Spotlight, and this is the best way to get information on such an important new feature.

The actions are currently only available via web markup. If you'd like to see that from native code, getting a bug report would be good.


The content type property in CSSearchableItemAttributeSet_General.h says:

//UTI Type pedigree for an item. Common types can be found in UTCoreTypes.h


The categories should be used in whatever way best fits your data. We're working on more documentation in this area, but for the moment use the properties that you think fit your content the best.

I cannot replicate the native message ,call,email but


As per Apple documentation :

For navigation use @property(copy, nullable) NSNumber*supportsNavigation of CSSearchableItemAttributeSet Class Reference

When an item includes

latitude
and
longitude
properties, these properties can be used for navigation to the location represented by the item. For example, it makes sense to set
supportsNavigation
to
1
for an item that represents review for a specific restaurant, but not for an item that represents a photo of a person.


For phonenumbers use @property(copy, nullable) NSNumber*supportsPhoneCall of CSSearchableItemAttributeSet Class Reference

When an item includes the

phoneNumbers
property, the phone number can be used to initiate phone calls. You can use the
supportsPhoneCall
property to indicate when making a phone call is appropriate and likely to be a primary action for the user. For example, you might set
supportsPhoneCall
to
1
for an item that represents a business, but not for an item that represents an academic paper that lists the phone numbers of the authors or the institution
Spotlight indexing for notes-like app
 
 
Q