Documentation Archive


App Search Programming Guide

Combine APIs to Increase Coverage

Core Spotlight, NSUserActivity, and web markup are designed to work together, so it’s best when you can combine these APIs in your app. Combining these APIs can give users even richer information and access to your content from more places.

In your app, using multiple APIs often means that you index the same content in more than one way. On these occasions, it's crucial that you relate the various representations of a single item so that you can avoid giving users duplicate items in search results. Avoiding duplication can also help improve the ranking of your items.

Use the following strategies to avoid creating duplicate representations of a single item:

  • If you’re using both NSUserActivity and Core Spotlight APIs to index an item, use the same value for relatedUniqueIdentifier and uniqueIdentifier to link the representations of the item. Note that if the Core Spotlight metadata for an item differs from an NSUserActivity object’s metadata for the same item, the Core Spotlight metadata is shown in search results and the NSUserActivity metadata is used in Siri suggestions.

  • If you’re using both NSUserActivity and web markup to index an item, set the user activity object’s webpageURL property to the relevant URL on your website.

  • If you’re using all three APIs, it works well to use the URL of the relevant webpage as the value for uniqueIdentifier, relatedUniqueIdentifier, and webpageURL.

Combining the search-related APIs also helps you index a broader range of your users’ interests. A good way to start your investigation into potential searchable items is to examine the analytics for your app. For example, you might index:

  • Content that the user views (using NSUserActivity)

  • Frequently used navigation points and features (using NSUserActivity)

  • Content created or curated by the user, such as photos or a list of favorites (using Core Spotlight APIs)

  • New messages, content, or items that arrive on the device (using Core Spotlight APIs)

  • Content that lives in both your app and your website (using web markup)

Ultimately, it’s essential to maintain a good engagement ratio for your searchable items so that they continue to be displayed in search results. The engagement ratio is based on the number of times that users tap an item related to your app and the number of app-related items that are displayed in search results. A low engagement ratio for an item can mean that the item won’t appear in search results. For some tips on ways to increase the engagement ratio for your items, see Improve the Ranking of Your Results.