Upload
windows-developer
View
242
Download
1
Embed Size (px)
Citation preview
#Build2016
Searching your App’s Data in UWPAdam WilsonProgram Manager
OutlineWhy search app data? Ways to search app data Indexed folder Content Indexer
Indexed folderUsing appcontent-ms filesIndexed folder sample
Content Indexer – the basicsPushing data in and checking the revision Searching and parsing the data coming outSample walkthrough
• Users expect to find their data quickly• Some data can’t be shared with other apps • Common example is data synced from a cloud service• Apps can leverage the system search
functionality for their own data• Easy to use• Powerful query language using Advanced Query Syntax (AQS)• The same local search engine as Cortana, File Explorer, Outlook, and
more• Saves dealing with internationalization
Why Use System Search For App Data?
• App writes data in a special, private, folder
• System manages making the data searchable
• Very simple to use, works with any data type
• Works best with static data
Indexed Folder
• Push model • App gives the data to the system to make it searchable
• Very flexible in the type of data that can be pushed in
• Best used with transient data
Content Indexer
Indexed Folder
• Create a folder called indexed in the app data folder
• Put files in the folder
• That’s it
Using the Indexed Folder
StorageFolder indexedFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("indexed");
StorageFile newIndexedFile = await indexedFolder.CreateFileAsync("IndexedFile.txt");
• Appcontent-ms files are metadata only files designed to work well with the indexed folder
• Follow the schema to create a file with the searchable data
• All the internationalization and AQS comes for free
Appcontent-ms files and the Indexed Folder
Demo
Indexed Folder
Content Indexer
1. Open up a connection to the system index
2. Create the item to be pushed3. Push the item into the index4. Make sure the index was updated• Watch for revision number jumps
Using the Content Indexer
App AppApp App
1.
2.
3.
4.
• Create a query and set the properties to be retrieved
• Parse the results back into your object model• Tip: Implementing IIndexableContent helps a lot
Pulling Data Out of the Content Indexer
App
?
App
?
App
?
1. Query for items
2. Receive query results
3. Parse back into object model
Demo
Content Indexer
Note on Reading the Property SystempropertyDescription name = System.Music.AlbumArtist shellPKey = PKEY_Music_AlbumArtist formatID = 56A3372E-CE9C-11D2-9F0E-006097C686F6 propID = 13 searchInfo inInvertedIndex = true isColumn = true isColumnSparse = true columnIndexType = OnDisk maxSize = 128 mnemonics = album artist
typeInfo type = String groupingRange = Discrete isInnate = false canBePurged multipleValues = false isGroup = false aggregationType = Default isTreeProperty = false isViewable = true isQueryable = true includeInFullTextQuery = false conditionType = String defaultOperation = Equal
propertyDescription name = System.DateModified shellPKey = PKEY_DateModified formatID = B725F130-47EF-101A-A5F1-02608C9EEBAC propID = 14 searchInfo inInvertedIndex = true isColumn = true isColumnSparse = false columnIndexType = OnDisk maxSize = 128 mnemonics = modified|date modified
typeInfo type = DateTime groupingRange = Discrete isInnate = true canBePurged multipleValues = false isGroup = false aggregationType = DateRange isTreeProperty = false isViewable = true isQueryable = true includeInFullTextQuery = false conditionType = String defaultOperation = Equal
Property System Docs: http://aka.ms/windowsproperties System.AlbumArtist: http://aka.ms/albumartist System.DateModified: http://aka.ms/datemodifiedProperty System Docs: http://aka.ms/windowsproperties System.AlbumArtist: http://aka.ms/albumartist System.DateModified: http://aka.ms/datemodified
Choosing Between the Content Indexer and Indexed Folder
Feature Content Indexer Indexed Folder
How data gets into the index App pushes the data, must listen to make sure indexing was successful
App creates files on the disk. Indexer manages the indexing process automatically
Type of data provided by app Property bags Any file type, metadata only appcontent-ms files can be used
Indexing Priority Control High priority and app controls indexing order
No control
Behaviour on reset App required to re-push data Indexer automatically reindexes all the files
RecapTwo ways to search app data in the systemBoth provide the same powerful query functionality
Indexed Folder Easier to use
Content IndexerProvides greater flexibility for your schema
© 2016 Microsoft Corporation. All rights reserved.