Class SearchService | Quick Search | 2.0.0
docs.unity3d.com
    Show / Hide Table of Contents

    Class SearchService

    Principal Quick Search API to initiate searches and fetch results.

    Inheritance
    Object
    SearchService
    Namespace: Unity.QuickSearch
    Syntax
    public static class SearchService

    Properties

    OrderedProviders

    Returns the list of providers sorted by priority.

    Declaration
    public static IEnumerable<SearchProvider> OrderedProviders { get; }
    Property Value
    Type Description
    IEnumerable<SearchProvider>

    Providers

    Returns the list of all providers (active or not)

    Declaration
    public static List<SearchProvider> Providers { get; }
    Property Value
    Type Description
    List<SearchProvider>

    Methods

    CreateContext(IEnumerable<String>, String, SearchFlags)

    Create context from a list of provider id.

    Declaration
    public static SearchContext CreateContext(IEnumerable<string> providerIds, string searchText = "", SearchFlags flags = SearchFlags.Sorted | SearchFlags.Default)
    Parameters
    Type Name Description
    IEnumerable<String> providerIds

    List of provider id

    String searchText

    seach Query

    SearchFlags flags

    Options defining how the query will be performed

    Returns
    Type Description
    SearchContext

    New SearchContext

    CreateContext(IEnumerable<SearchProvider>, String, SearchFlags)

    Create context from a list of providers.

    Declaration
    public static SearchContext CreateContext(IEnumerable<SearchProvider> providers, string searchText = "", SearchFlags flags = SearchFlags.Sorted | SearchFlags.Default)
    Parameters
    Type Name Description
    IEnumerable<SearchProvider> providers

    List of providers

    String searchText

    seach Query

    SearchFlags flags

    Options defining how the query will be performed

    Returns
    Type Description
    SearchContext

    New SearchContext

    GetAction(SearchProvider, String)

    Returns the search action data for a given provider and search action id.

    Declaration
    public static SearchAction GetAction(SearchProvider provider, string actionId)
    Parameters
    Type Name Description
    SearchProvider provider

    Provider to lookup

    String actionId

    Unique action ID within the provider.

    Returns
    Type Description
    SearchAction

    The matching action

    GetItems(SearchContext, SearchFlags)

    Initiate a search and return all search items matching the search context. Other items can be found later using the asynchronous searches.

    Declaration
    public static List<SearchItem> GetItems(SearchContext context, SearchFlags options = SearchFlags.Sorted | SearchFlags.Default)
    Parameters
    Type Name Description
    SearchContext context

    The current search context

    SearchFlags options

    Options defining how the query will be performed

    Returns
    Type Description
    List<SearchItem>

    A list of search items matching the search query.

    GetKeywords(SearchContext, String)

    Returns a list of keywords used by auto-completion for the active providers.

    Declaration
    public static string[] GetKeywords(SearchContext context, string lastToken)
    Parameters
    Type Name Description
    SearchContext context

    Current search context

    String lastToken

    Search token currently being typed.

    Returns
    Type Description
    String[]

    A list of keywords that can be shown in an auto-complete dropdown.

    GetProvider(String)

    Returns the data of a search provider given its ID.

    Declaration
    public static SearchProvider GetProvider(string providerId)
    Parameters
    Type Name Description
    String providerId

    Unique ID of the provider

    Returns
    Type Description
    SearchProvider

    The matching provider

    LoadExpression(String, SearchFlags)

    Load a search expression asset.

    Declaration
    public static ISearchExpression LoadExpression(string expressionPath, SearchFlags options = SearchFlags.Sorted | SearchFlags.Default)
    Parameters
    Type Name Description
    String expressionPath

    Asset path of the search expression

    SearchFlags options

    Options defining how the query will be performed

    Returns
    Type Description
    ISearchExpression

    Returns a SearchExpression ready to be evaluated.

    ParseExpression(String, SearchFlags)

    Parse a simple json document string as a SearchExpression.

    Declaration
    public static ISearchExpression ParseExpression(string sjson, SearchFlags options = SearchFlags.Sorted | SearchFlags.Default)
    Parameters
    Type Name Description
    String sjson

    Simple Json string defining a SearchExpression

    SearchFlags options

    Options defining how the query will be performed

    Returns
    Type Description
    ISearchExpression

    Returns a SearchExpression ready to be evaluated.

    Refresh()

    Clears everything and reloads all search providers.

    Declaration
    public static void Refresh()
    Remarks

    Use with care. Useful for unit tests.

    Request(SearchContext, SearchFlags)

    Execute a search request that will fetch search results asynchronously.

    Declaration
    public static ISearchList Request(SearchContext context, SearchFlags options = SearchFlags.None)
    Parameters
    Type Name Description
    SearchContext context

    Search context used to track asynchronous request.

    SearchFlags options

    Options defining how the query will be performed

    Returns
    Type Description
    ISearchList

    Asynchronous list of search items.

    SetActive(String, Boolean)

    Activate or deactivate a search provider. Call Refresh after this to take effect on the next search.

    Declaration
    public static void SetActive(string providerId, bool active = true)
    Parameters
    Type Name Description
    String providerId

    Provider id to activate or deactivate

    Boolean active

    Activation state

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023