Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

SearchIndexer Constructor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public SearchIndexer(string name, string filePath);

Parameters

Parameter Description
name Name of the indexer.
filePath Path of the indexer on disk.

Description

Creates a new SearchIndexer.

using UnityEditor;
using UnityEditor.Search;
using UnityEngine;

static class Example_SearchIndexer
{
    [MenuItem("Examples/SearchIndexer/Class")]
    public static void Run()
    {
        // Create a search indexer saved in the project temp folder
        using var searchIndexer = new SearchIndexer("SearchIndexerExample", FileUtil.GetUniqueTempPathInProject());

        // Indicate that searchIndexer is about to index documents
        searchIndexer.Start();

        // Add some documents
        var unityDocumentIndex = searchIndexer.AddDocument("Unity Technologies");

        // Index some words
        var baseScore = 42;
        searchIndexer.AddWord("unity", baseScore, unityDocumentIndex);
        searchIndexer.AddWord("is", baseScore, unityDocumentIndex);
        searchIndexer.AddWord("awesome", baseScore, unityDocumentIndex);

        // Indicate that searchIndexer is finished indexing documents and is ready to search.
        searchIndexer.Finish();

        // Wait for the indexation to finish.
        while (!searchIndexer.IsReady())
            ;

        // Search the index
        foreach (var result in searchIndexer.Search("uni"))
            Debug.Log($"Found document [{result.index}] {result.id} ({result.score})");
    }
}


Obsolete This constructor is no longer supported. Please use SearchIndexer(string name, string filePath).

Declaration

public SearchIndexer();
Obsolete This constructor is no longer supported. Please use SearchIndexer(string name, string filePath).

Declaration

public SearchIndexer(string name);

Parameters

Parameter Description
name Name of the indexer.

Description

Creates a new default SearchIndexer.