ContentIndexer
ContentIndexer
ContentIndexer
ContentIndexer
Class
Definition
Enables Windows Store apps to make private content searchable by using the system index.
public : sealed class ContentIndexer : IContentIndexer, IContentIndexerQueryOperationspublic sealed class ContentIndexer : IContentIndexer, IContentIndexerQueryOperationsPublic NotInheritable Class ContentIndexer Implements IContentIndexer, IContentIndexerQueryOperations// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Examples
Content indexer sample (Windows 10)
Video Walkthrough of a demo app
Remarks
The ContentIndexer class enables apps to push a property bag into the system index which can later be searched quickily by the app or user. The property bag can contain any properties from the shell property system and is available to search instantly after the API call returns.
The properties are defined as string-object key-value pairs, where the keys are standard Windows property names, like System.Author, and the values are PropertyValue instances. The property must be registered on the system and have isColumn and isInvertedIndex set to true. You can also provide full-text search content by using a stream and content type. This corresponds to running the IFilter implementation for the type and indexing the content.
You can query over content by using Advanced Query Syntax (AQS).
Don't use the index as a primary data store, the index is only a cache of searchable properties. All data in the index must be stored elsewhere in case the cache is lost. Content is separated per app package and per user. A package can't query another package's data, but the operating system can access any data that is pushed in.
For more information on the properties available to use, see the Windows Property System.
Properties
Revision Revision Revision Revision
Gets the version of the ContentIndexer.
public : ulong Revision { get; }public ulong Revision { get; }Public ReadOnly Property Revision As ulong// You can use this property in JavaScript.
- Value
- ulong ulong ulong ulong
The revision number.
Remarks
Use the Revision property to track updates to the index.
For example, it's possible that your app may have terminated prior to the index being committed. In many cases the app can resubmit all of its content, but for more sophisticated apps, like mail, where there's a large amount of content, the app can create its own checkpoints and re-index only the missing content. The app can track how much content has been indexed by tracking the revision number. The Revision property is a number that increments based on the indexing operations that the app has initiated.
If the index is reset (which can be caused by either the index getting corrupted or a user manually clearing it out), the revision number will be "0". In this case, the app should re-push all of its data.
- See Also
Methods
AddAsync(IIndexableContent) AddAsync(IIndexableContent) AddAsync(IIndexableContent) AddAsync(IIndexableContent)
Adds app-defined items with properties and content to the system index.
public : IAsyncAction AddAsync(IIndexableContent indexableContent)public IAsyncAction AddAsync(IIndexableContent indexableContent)Public Function AddAsync(indexableContent As IIndexableContent) As IAsyncAction// You can use this method in JavaScript.
- indexableContent
- IIndexableContent IIndexableContent IIndexableContent IIndexableContent
The content properties to index.
- See Also
CreateQuery(String, IIterable)
CreateQuery(String, IIterable)
CreateQuery(String, IIterable)
CreateQuery(String, IIterable)
Builds a query with the specified search filter and identifies which properties to retrieve.
public : ContentIndexerQuery CreateQuery(PlatForm::String searchFilter, IIterable<PlatForm::String> propertiesToRetrieve)public ContentIndexerQuery CreateQuery(String searchFilter, IEnumerable<String> propertiesToRetrieve)Public Function CreateQuery(searchFilter As String, propertiesToRetrieve As IEnumerable<String>) As ContentIndexerQuery// You can use this method in JavaScript.
- searchFilter
- PlatForm::String String String String
The Advanced Query Syntax (AQS) filter to apply.
- propertiesToRetrieve
- IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>
The properties to retrieve, specified by their Windows canonical property names.
Remarks
Call the GetPropertiesAsync method to run the query.
CreateQuery(String, IIterable, IIterable)
CreateQuery(String, IIterable, IIterable)
CreateQuery(String, IIterable, IIterable)
CreateQuery(String, IIterable, IIterable)
Builds a query with the specified search filter, sort order, and identifies which properties to retrieve.
public : ContentIndexerQuery CreateQuery(PlatForm::String searchFilter, IIterable<PlatForm::String> propertiesToRetrieve, IIterable<SortEntry> sortOrder)public ContentIndexerQuery CreateQuery(String searchFilter, IEnumerable<String> propertiesToRetrieve, IEnumerable<SortEntry> sortOrder)Public Function CreateQuery(searchFilter As String, propertiesToRetrieve As IEnumerable<String>, sortOrder As IEnumerable<SortEntry>) As ContentIndexerQuery// You can use this method in JavaScript.
- searchFilter
- PlatForm::String String String String
The Advanced Query Syntax (AQS) filter.
- propertiesToRetrieve
- IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>
The properties to retrieve, specified by their Windows canonical property names.
- sortOrder
- IIterable<SortEntry> IEnumerable<SortEntry> IEnumerable<SortEntry> IEnumerable<SortEntry>
The sort order for the filtered results.
CreateQuery(String, IIterable, IIterable, String)
CreateQuery(String, IIterable, IIterable, String)
CreateQuery(String, IIterable, IIterable, String)
CreateQuery(String, IIterable, IIterable, String)
Builds a query with the specified search filter, sort order, filter language, and identifies which properties to retrieve.
public : ContentIndexerQuery CreateQuery(PlatForm::String searchFilter, IIterable<PlatForm::String> propertiesToRetrieve, IIterable<SortEntry> sortOrder, PlatForm::String searchFilterLanguage)public ContentIndexerQuery CreateQuery(String searchFilter, IEnumerable<String> propertiesToRetrieve, IEnumerable<SortEntry> sortOrder, String searchFilterLanguage)Public Function CreateQuery(searchFilter As String, propertiesToRetrieve As IEnumerable<String>, sortOrder As IEnumerable<SortEntry>, searchFilterLanguage As String) As ContentIndexerQuery// You can use this method in JavaScript.
- searchFilter
- PlatForm::String String String String
The Advanced Query Syntax (AQS) filter to apply.
- propertiesToRetrieve
- IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>
The properties to retrieve, specified by their Windows canonical property names.
- sortOrder
- IIterable<SortEntry> IEnumerable<SortEntry> IEnumerable<SortEntry> IEnumerable<SortEntry>
The sort order for the filtered results.
- searchFilterLanguage
- PlatForm::String String String String
The language that's used to parse Advanced Query Syntax (AQS), specified as a BCP-47 language tag.
DeleteAllAsync() DeleteAllAsync() DeleteAllAsync() DeleteAllAsync()
Removes all app-defined items from the ContentIndexer.
public : IAsyncAction DeleteAllAsync()public IAsyncAction DeleteAllAsync()Public Function DeleteAllAsync() As IAsyncAction// You can use this method in JavaScript.
- See Also
DeleteAsync(String) DeleteAsync(String) DeleteAsync(String) DeleteAsync(String)
Removes the specified app-defined item from the ContentIndexer.
public : IAsyncAction DeleteAsync(PlatForm::String contentId)public IAsyncAction DeleteAsync(String contentId)Public Function DeleteAsync(contentId As String) As IAsyncAction// You can use this method in JavaScript.
- contentId
- PlatForm::String String String String
The identifier of the item to remove.
- See Also
DeleteMultipleAsync(IIterable)
DeleteMultipleAsync(IIterable)
DeleteMultipleAsync(IIterable)
DeleteMultipleAsync(IIterable)
Removes the specified app-defined items from the ContentIndexer.
public : IAsyncAction DeleteMultipleAsync(IIterable<PlatForm::String> contentIds)public IAsyncAction DeleteMultipleAsync(IEnumerable<String> contentIds)Public Function DeleteMultipleAsync(contentIds As IEnumerable<String>) As IAsyncAction// You can use this method in JavaScript.
- contentIds
- IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>
The identifier of the item to remove.
GetIndexer() GetIndexer() GetIndexer() GetIndexer()
Gets an existing per-app index or creates a new one, if necessary.
public : static ContentIndexer GetIndexer()public static ContentIndexer GetIndexer()Public Static Function GetIndexer() As ContentIndexer// You can use this method in JavaScript.
The index.
- See Also
GetIndexer(String) GetIndexer(String) GetIndexer(String) GetIndexer(String)
Gets the per-app index with the specified name or creates a new one, if necessary.
public : static ContentIndexer GetIndexer(PlatForm::String indexName)public static ContentIndexer GetIndexer(String indexName)Public Static Function GetIndexer(indexName As String) As ContentIndexer// You can use this method in JavaScript.
- indexName
- PlatForm::String String String String
The index name.
The index.
Remarks
The app can provide an indexName identifier that it can use to partition data for its own queries. This identifier is included as part of the item scope, which means that it's faster to partition based on this scope than by filtering with a property. The approach has the cost of being unable to query easily across multiple scopes.
- See Also
RetrievePropertiesAsync(String, IIterable)
RetrievePropertiesAsync(String, IIterable)
RetrievePropertiesAsync(String, IIterable)
RetrievePropertiesAsync(String, IIterable)
Gets content properties based on the given content identifier.
public : IAsyncOperation<IMapView<PlatForm::String, PlatForm::Object>> RetrievePropertiesAsync(PlatForm::String contentId, IIterable<PlatForm::String> propertiesToRetrieve)public IAsyncOperation<IReadOnlyDictionary<string, object>> RetrievePropertiesAsync(String contentId, IEnumerable<String> propertiesToRetrieve)Public Function RetrievePropertiesAsync(contentId As String, propertiesToRetrieve As IEnumerable<String>) As IAsyncOperation( Of IReadOnlyDictionarystring, object )// You can use this method in JavaScript.
- contentId
- PlatForm::String String String String
The identifier for the content properties.
- propertiesToRetrieve
- IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>
The retrieved properties, based on contentId.
When this method completes, it returns the retrieved properties as a map of key-value pairs.
UpdateAsync(IIndexableContent) UpdateAsync(IIndexableContent) UpdateAsync(IIndexableContent) UpdateAsync(IIndexableContent)
Updates app content and properties in the ContentIndexer.
public : IAsyncAction UpdateAsync(IIndexableContent indexableContent)public IAsyncAction UpdateAsync(IIndexableContent indexableContent)Public Function UpdateAsync(indexableContent As IIndexableContent) As IAsyncAction// You can use this method in JavaScript.
- indexableContent
- IIndexableContent IIndexableContent IIndexableContent IIndexableContent
The content properties to update.
- See Also