SearchPaneQueryLinguisticDetails SearchPaneQueryLinguisticDetails SearchPaneQueryLinguisticDetails SearchPaneQueryLinguisticDetails Class

Definition

Provides information about query text that the user enters through an Input Method Editor (IME).

public : sealed class SearchPaneQueryLinguisticDetails : ISearchPaneQueryLinguisticDetailspublic sealed class SearchPaneQueryLinguisticDetails : ISearchPaneQueryLinguisticDetailsPublic NotInheritable Class SearchPaneQueryLinguisticDetails Implements ISearchPaneQueryLinguisticDetails// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The Search contract sample demonstrates how to respond to a suggestionsrequested event, including how to access the event's linguistic details.

private void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
{
    var queryText = e.QueryText;
    if (string.IsNullOrEmpty(queryText))
    {
        MainPage.Current.NotifyUser("Use the search pane to submit a query", NotifyType.StatusMessage);
    }
    else
    {
        var request = e.Request;
        var linguisticDetails = e.LinguisticDetails;
        foreach (string alternative in linguisticDetails.QueryTextAlternatives)
        {
            foreach (string suggestion in suggestionList)
            {
                if (suggestion.StartsWith(alternative, StringComparison.CurrentCultureIgnoreCase))
                {
                    // Add suggestion to Search Pane
                    request.SearchSuggestionCollection.AppendQuerySuggestion(suggestion);

                    // Break since the Search Pane can show at most 5 suggestions
                    if (request.SearchSuggestionCollection.Size >= MainPage.SearchPaneMaxSuggestions)
                    {
                        break;
                    }
                }
            }

            // Break since the Search Pane can show at most 5 suggestions
            if (request.SearchSuggestionCollection.Size >= MainPage.SearchPaneMaxSuggestions)
            {
                break;
            }
        }

        if (request.SearchSuggestionCollection.Size > 0)
        {
            MainPage.Current.NotifyUser("Suggestions provided for query: " + queryText, NotifyType.StatusMessage);
        }
        else
        {
            MainPage.Current.NotifyUser("No suggestions provided for query: " + queryText, NotifyType.StatusMessage);
        }
    }
}
// Register the onsuggestionsrequested event in your apps global scope, for example default.js, so that it is registered as soon as your app is launched.
Windows.ApplicationModel.Search.SearchPane.getForCurrentView().onsuggestionsrequested = function (eventObject) {
    var queryText = eventObject.queryText, suggestionRequest = eventObject.request, linguisticDetails = eventObject.linguisticDetails;

    var queryAlternatives = linguisticDetails.queryTextAlternatives;
    var maxNumberOfSuggestions = 5;
    for (var i = 0, len = queryAlternatives.length, done = false; i < len && !done; i++) {
        // toLowerCase not necessary for East Asian languages. Preserves compatibility when non East Asian suggestions are mixed in with East Asian suggestions.
        var alternative = queryAlternatives[i].toLowerCase();
        for (var j = 0, suggestionLength = suggestionList.length; j < suggestionLength; j++) {
            if (suggestionList[j].substr(0, alternative.length).toLowerCase() === alternative) {
                suggestionRequest.searchSuggestionCollection.appendQuerySuggestion(suggestionList[j]);
                if (suggestionRequest.searchSuggestionCollection.size === maxNumberOfSuggestions) {
                    done = true;
                    break;
                }
            }
        }
    }

    // Construct list of alternatives so we can output them.
    var alternatives = "";
    for (var k = 0, alternativeCount = queryAlternatives.length; k < alternativeCount; k++) {
        alternatives += queryAlternatives[k];
    }
    if (suggestionRequest.searchSuggestionCollection.size > 0) {
        WinJS.log && WinJS.log("Suggestions provided for query: " + queryText + "\nUsing alternatives: " + alternatives, "sample", "status");
    } else {
        WinJS.log && WinJS.log("No suggestions provided for query: " + queryText + "\nUsing alternatives: " + alternatives, "sample", "status");
    }
};

Remarks

An app retrieves this object through the searchPaneQueryChangedEventArgs.linguisticDetails property while handling a querychanged event or through the searchPaneSuggestionsRequestedEventArgs.linguisticDetails property while handling a suggestionsrequested event.

Properties

QueryTextAlternatives QueryTextAlternatives QueryTextAlternatives QueryTextAlternatives

A list of the text alternatives for the current query text. These alternatives account for uncomposed text the user is entering in an IME.

public : IVectorView<string> QueryTextAlternatives { get; }public IReadOnlyList<string> QueryTextAlternatives { get; }Public ReadOnly Property QueryTextAlternatives As IReadOnlyList<string>// You can use this property in JavaScript.
Value
IVectorView<PlatForm::String> IReadOnlyList<string> IReadOnlyList<string> IReadOnlyList<string>

A list of the text alternatives for the query text.

See Also

QueryTextCompositionLength QueryTextCompositionLength QueryTextCompositionLength QueryTextCompositionLength

The length of the portion of the query text that the user is composing with an Input Method Editor (IME).

public : unsigned int QueryTextCompositionLength { get; }public uint QueryTextCompositionLength { get; }Public ReadOnly Property QueryTextCompositionLength As uint// You can use this property in JavaScript.
Value
unsigned int uint uint uint

The length of the portion of the query text that the user is composing with an Input Method Editor (IME).

See Also

QueryTextCompositionStart QueryTextCompositionStart QueryTextCompositionStart QueryTextCompositionStart

The starting location of the text that the user is composing with an Input Method Editor (IME).

public : unsigned int QueryTextCompositionStart { get; }public uint QueryTextCompositionStart { get; }Public ReadOnly Property QueryTextCompositionStart As uint// You can use this property in JavaScript.
Value
unsigned int uint uint uint

The starting location of the query text that the user is composing with an Input Method Editor (IME).

See Also

See Also