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

    Class SearchIndexer

    Base class for an Indexer of document which allow retrieving of a document given a specific pattern in roughly log(n).

    Inheritance
    Object
    SearchIndexer
    ObjectIndexer
    Namespace: Unity.QuickSearch
    Syntax
    public class SearchIndexer

    Constructors

    SearchIndexer()

    Create a new default SearchIndexer.

    Declaration
    public SearchIndexer()

    SearchIndexer(String)

    Create a new SearchIndexer.

    Declaration
    public SearchIndexer(string name)
    Parameters
    Type Name Description
    String name

    Name of the indexer

    Fields

    m_ThreadAborted

    Is the current indexing thread aborted.

    Declaration
    protected volatile bool m_ThreadAborted
    Field Value
    Type Description
    Boolean

    Properties

    getQueryTokensHandler

    Handler used to parse and split the search query text into words. The tokens needs to be split similarly to words and properties are indexed.

    Declaration
    public Func<string, string[]> getQueryTokensHandler { get; set; }
    Property Value
    Type Description
    Func<String, String[]>

    name

    Name of the document. Generally this name is given by a user from a Unity.QuickSearch.SearchDatabase.Settings

    Declaration
    public string name { get; set; }
    Property Value
    Type Description
    String

    skipEntryHandler

    Handler used to skip some entries.

    Declaration
    public Func<string, bool> skipEntryHandler { get; set; }
    Property Value
    Type Description
    Func<String, Boolean>

    Methods

    AddExactWord(String, Int32, Int32)

    Add a new word coming from a specific document to the index. The word will be added as an exact match.

    Declaration
    public void AddExactWord(string word, int score, int documentIndex)
    Parameters
    Type Name Description
    String word

    Word to add to the index.

    Int32 score

    Relevance score of the word.

    Int32 documentIndex

    Document where the indexed word was found.

    AddNumber(String, Double, Int32, Int32)

    Add a key-number value pair to the index. The key won't be added with variations.

    Declaration
    public void AddNumber(string key, double value, int score, int documentIndex)
    Parameters
    Type Name Description
    String key

    Key used to retrieve the value.

    Double value

    Number value to store in the index.

    Int32 score

    Relevance score of the word.

    Int32 documentIndex

    Document where the indexed value was found.

    AddProperty(String, String, Int32, Boolean, Boolean)

    Add a property value to the index. A property is specified with a key and a string value. The value will be stored with multiple variations.

    Declaration
    public void AddProperty(string key, string value, int documentIndex, bool saveKeyword = false, bool exact = true)
    Parameters
    Type Name Description
    String key

    Key used to retrieve the value.

    String value

    String value to store in the index.

    Int32 documentIndex

    Document where the indexed value was found.

    Boolean saveKeyword

    Define if we store this key in the keyword registry of the index. See Unity.QuickSearch.SearchIndexer.GetKeywords.

    Boolean exact

    If true, we will store also an exact match entry for this word.

    AddProperty(String, String, Int32, Int32, Boolean, Boolean)

    Add a property value to the index. A property is specified with a key and a string value. The value will be stored with multiple variations.

    Declaration
    public void AddProperty(string key, string value, int score, int documentIndex, bool saveKeyword = false, bool exact = true)
    Parameters
    Type Name Description
    String key

    Key used to retrieve the value.

    String value

    String value to store in the index.

    Int32 score

    Relevance score of the word.

    Int32 documentIndex

    Document where the indexed value was found.

    Boolean saveKeyword

    Define if we store this key in the keyword registry of the index. See Unity.QuickSearch.SearchIndexer.GetKeywords.

    Boolean exact

    If true, we will store also an exact match entry for this word.

    AddProperty(String, String, Int32, Int32, Int32, Int32, Boolean, Boolean)

    Add a property value to the index. A property is specified with a key and a string value. The value will be stored with multiple variations.

    Declaration
    public void AddProperty(string name, string value, int minVariations, int maxVariations, int score, int documentIndex, bool saveKeyword = false, bool exact = true)
    Parameters
    Type Name Description
    String name

    Key used to retrieve the value.

    String value

    String value to store in the index.

    Int32 minVariations

    Minimum number of variations to compute for the value. Cannot be higher than the length of the word.

    Int32 maxVariations

    Maximum number of variations to compute for the value. Cannot be higher than the length of the word.

    Int32 score

    Relevance score of the word.

    Int32 documentIndex

    Document where the indexed value was found.

    Boolean saveKeyword

    Define if we store this key in the keyword registry of the index. See Unity.QuickSearch.SearchIndexer.GetKeywords.

    Boolean exact

    If true, we will store also an exact match entry for this word.

    AddWord(String, Int32, Int32)

    Add a new word coming from a specific document to the index. The word will be added with multiple variations allowing partial search.

    Declaration
    public void AddWord(string word, int score, int documentIndex)
    Parameters
    Type Name Description
    String word

    Word to add to the index.

    Int32 score

    Relevance score of the word.

    Int32 documentIndex

    Document where the indexed word was found.

    AddWord(String, Int32, Int32, Int32)

    Add a new word coming from a specific document to the index. The word will be added with multiple variations allowing partial search.

    Declaration
    public void AddWord(string word, int size, int score, int documentIndex)
    Parameters
    Type Name Description
    String word

    Word to add to the index.

    Int32 size

    Number of variations to compute.

    Int32 score

    Relevance score of the word.

    Int32 documentIndex

    Document where the indexed word was found.

    AddWord(String, Int32, Int32, Int32, Int32)

    Add a new word coming from a specific document to the index. The word will be added with multiple variations allowing partial search.

    Declaration
    public void AddWord(string word, int minVariations, int maxVariations, int score, int documentIndex)
    Parameters
    Type Name Description
    String word

    Word to add to the index.

    Int32 minVariations

    Minimum number of variations to compute. Cannot be higher than the length of the word.

    Int32 maxVariations

    Maximum number of variations to compute. Cannot be higher than the length of the word.

    Int32 score

    Relevance score of the word.

    Int32 documentIndex

    Document where the indexed word was found.

    Build()

    Build custom derived indexes.

    Declaration
    public virtual void Build()

    IndexDocument(String, Boolean)

    Function to override in a concrete SearchIndexer to index the content of a document.

    Declaration
    public virtual void IndexDocument(string document, bool checkIfDocumentExists)
    Parameters
    Type Name Description
    String document

    Path of the document to index.

    Boolean checkIfDocumentExists

    Check if the document actually exists.

    IsReady()

    Is the index fully built and up to date and ready for search.

    Declaration
    public bool IsReady()
    Returns
    Type Description
    Boolean

    Returns true if the index is ready for search.

    LoadBytes(Byte[], Action<Boolean>)

    Load asynchronously (i.e. in another thread) the index from a binary buffer.

    Declaration
    public bool LoadBytes(byte[] bytes, Action<bool> finished)
    Parameters
    Type Name Description
    Byte[] bytes

    Binary buffer containing the index representation.

    Action<Boolean> finished

    Callback that will trigger when the index is fully loaded. The callback parameters indicate if the loading was succesful.

    Returns
    Type Description
    Boolean

    Returns false if the index is of an unsupported version or if there was a problem initializing the reading thread.

    Read(Stream, Boolean)

    Read a stream and populate the index from it.

    Declaration
    public bool Read(Stream stream, bool checkVersionOnly)
    Parameters
    Type Name Description
    Stream stream

    Stream where to read the index from.

    Boolean checkVersionOnly

    If true, it will only read the version of the index and stop reading any more content.

    Returns
    Type Description
    Boolean

    Returns false if the version of the index is not supported.

    SaveBytes()

    Get the bytes representation of this index. See Write(Stream).

    Declaration
    public byte[] SaveBytes()
    Returns
    Type Description
    Byte[]

    Bytes representation of the index.

    Search(String, Int32, Int32)

    Run a search query in the index.

    Declaration
    public virtual IEnumerable<SearchResult> Search(string query, int maxScore = 2147483647, int patternMatchLimit = 2999)
    Parameters
    Type Name Description
    String query

    Search query to look out for. If if matches any of the indexed variations a result will be returned.

    Int32 maxScore

    Maximum score of any matched Search Result. See score.

    Int32 patternMatchLimit

    Maximum number of matched Search Result that can be returned. See SearchResult.

    Returns
    Type Description
    IEnumerable<SearchResult>

    Returns a collection of Search Result matching the query.

    SkipEntry(String, Boolean)

    Called when the index is built to see if a specified document needs to be indexed. See skipEntryHandler

    Declaration
    public virtual bool SkipEntry(string document, bool checkRoots = false)
    Parameters
    Type Name Description
    String document

    Path of a document

    Boolean checkRoots
    Returns
    Type Description
    Boolean

    Returns true if the document doesn't need to be indexed.

    Write(Stream)

    Write a binary representation of the the index on a stream.

    Declaration
    public void Write(Stream stream)
    Parameters
    Type Name Description
    Stream stream

    Stream where to write the index.

    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