relatedUniqueIdentifier issue

I take it back, I've got NSUserActivity indexing to work on b3.


I've narrowed the issue down to the following:


If i set a relatedUniqueIdentifier (to anything) in a CSSearchableItemAttributeSet which is assigned to the NSUserActivity, the item doesn't get indexed.


If I leave the item without a uniqueID, it gets indexed.


This however poses a problem in regards to the whole de-duplication thing!


If I have time tomorrow I'll post a radar. Anyone else have this issue? Just me?

Accepted Reply

You need to add the item to the index first. You should be able to simply add it to the index with the unique identifier, even with minimal information, and then you could (if necessary) update it later. If you're setting the relatedUniqueIdentifier, then that identifier needs to be in the index.

Replies

Please get a bug report filed ASAP with a sample project attached.

Bug filed as 21871508 with sample project.


Thanks!

That's super helpful, we'll take a look at it!

My bug was closed as "works as expected". So that means I either didn't explain myself very well, or I don't understand relatedUniqueIdentifier.


I was under the impression that relatedUniqueIdentifier could be used to that in the event the same content is added to the index either via Core Spotlight or via the AppleBot that it would enable de-duplication: See iOS 9.0 release notes:


When you combine multiple Search APIs, items can get indexed from multiple places. To avoid giving users duplicate items in search results, you need to link item IDs appropriately. To ensure that item IDs are linked, you can use the same value in a searchable item’s

uniqueIdentifier
property and in the
relatedUniqueIdentifier
property within an
NSUserActivity
object’s
contentAttributes
property. If you use all three APIs, it works well to use a specific URL as the value that uniquely identifies an item. (You can also set an
NSUserActivity
object’s
webpageURL
property to the URL for an item.)


So how am I supposed to do that if I can't use the relatedUniqueIdentifier property when trying to index an NSUserActivity?

I too am having this problem. Populating the relatedUniqueIdentifier field to anything will prevent me from indexing. I want to be able to delete the activity.

Don't understand why matttancock's bug was closed.

I'm also affected by this and I've logged radar 21958439 (also on Open Radar).

The only thing I can guess (as I didn't get any clarification on my closed radar as I requested) is that somewhere there's an assumption that relatedUniqueIdentifier will only be used when you're associating a userActivity with an already indexed Core Spotlight item. And therefore the NSUserActivity doesn't need indexing, but is just more of a +1.


Unfortunately this assumption is either faulty or just severely limiting depending on the possible circumstances:


1) What if we don't know which will get indexed first. (We potentially have some control over this, but it's still potentially limiting)

2) What if we're trying to associated an NSUserActivity with an item which is _potentially_ indexed by the web indexer? (We have no control over when/if the item will be indexed by the AppleBot)


I've asked more than once, but how are we supposed to relate those indexing activities if we can't use relatedUniqueIdentifier?

Still waiting for clarification on this. Thanks

I would also like an answer to this too.


For my situation, I want to add an user activity when the user visits a page. I also want to add a searchable item when the user marks the page and delete the item when the user unmarks the page. If the user activity is added before user marks the page (so before the related searchable item is added), then the user activity doesn't seem to be indexed.


Thanks.

I have the same issue...

When I set a value for this attribute, the activity is not indexed.

So, what's the solution to index only once time the activity without unique identifier ?

You need to add the item to the index first. You should be able to simply add it to the index with the unique identifier, even with minimal information, and then you could (if necessary) update it later. If you're setting the relatedUniqueIdentifier, then that identifier needs to be in the index.

Hi,

Could you please clarify that when using CoreSpotlight in combination with NSUserActivities that have public indexing enabled. When the user taps the search result does the search item (NSUserActivity) still get sent for public indexing?


Thanks

This sounds like an unrelated question to this thread. I'd prefer if you could create a new topic to track this question (so that people can find it in the forums instead of it being buried in a thread with a completely different title).

Currently I'm only indexing user content (in my case things they favorite) so I have the same problem with NSUserActivity when a user views something that isn't one of their favorites. I was setting relatedUniqueIdentifier to the web URL to link up with out web markup. Is this not correct? Or to pair up with our web content do I need to add all activity to the local index whenever I create/update a user activity?

To pair a NSUserActivity up to web content you'd set the webpageURL. But if you're indexing user content then you definitely want to use CoreSpotlight to put that in the index. Then NSUserActivity would be used when the user actually viewed or interacted with that content in your app. In that case you'd want to set the webpageURL to match your web content and the relatedUniqueIdentifier to match your (already inserted) CoreSpotlight entries.