StorageFile.GetSearchHits | getSearchHits method
Gets the search hits specified in a query.
Syntax
var iMap = storageFile.getSearchHits(queryOptions);
public IDictionary<String, IVectorView> GetSearchHits(
QueryOptions queryOptions
)
Public Function GetSearchHits(
queryOptions As QueryOptions
) As IDictionary(Of String, IVectorView)
public:
IMap<String, IVectorView>^ GetSearchHits(
QueryOptions^ queryOptions
)
Parameters
queryOptions
Type: QueryOptionsThe object that specifies the query.
Return value
Type: IMap<String, IVectorView> [JavaScript/C++] | System.Collections.Generic.IDictionary<String, IVectorView> [.NET]
When this method completes, it returns the object that you use to get the hits.
Examples
The example code demonstrates how to use GetSearchHits.
// simple AQS case
var hitFinder = new Windows.Storage.Search.HitFinder(“tree”, “en-us”);
var hits = hitFinder.Find("a string value with tree, there are multiple hits for tree in this string”);
hits.forEach(function(hit) {
});
var hitFinder = new Windows.Storage.Search.HitFinder(“tree”);
var hits = hitFinder.Find("a string value with tree, there are multiple hits for tree in this string”);
hits.forEach(function(hit) {
});
// composed with a file query
var DocLibrary = Windows.Storage.KnownFolders.DocumentsLibrary;
var queryOptions = new Windows.Storage.Search.QueryOptions;
queryOptions.indexerOption =
Windows.Storage.Search.IndexerOption.OnlyUseIndexer;
queryOptions.UserSearchFilter = “tree”;
queryOptions.Language = “en-us”;
var queryResult = DocLibrary.CreateFileQueryWithOptions(queryOptions);
queryResult.getFilesAsync().done(function (files)
{
files.forEach(function (file) {
var filehits = file.GetSearchHits(queryOptions);
var hits = filehits.Lookup(“System.FileName”);
if (hits.size != 0)
{
var txt = document.getElementById("FileNameTextBox");
hits.forEach(function(hit) {
// Highlight each hit in the text contained in the
// “txt” element (which contains the text from the
// “System.FileName” property).
});
}
// Continue this pattern for every text control displayed
// in the UI that contains property values for this “file”.
});
});
// write the sample that demonstrates utilizing the query result, the
// query hits property, iterating over those query hit property values
// and using this method.
// consider construting this from the StorageFile result
// consider how data binding works with this and write the end to end on that.
var hits = hitFinder.FindMatchingXXX(stringToFindIn, fileResult);
hits.forEach(function(hits) {
});
Requirements
Minimum supported client |
Windows 8.1 Preview |
Minimum supported server |
Windows Server 2012 R2 Preview |
Namespace |
Windows.Storage Windows::Storage [C++] |
Metadata |
Windows.winmd |
See also
Send comments about this topic to Microsoft
Build date: 10/2/2013