版本:Unity 6 (6000.0)
语言英语
  • C#

搜索索引器.最小单词索引化长度

建议更改

成功!

感谢您帮助我们改善 Unity 文档的质量。尽管我们无法接受所有提交,但我们确实阅读用户提出的每一项变更建议,并在适用时进行更新。

关闭

提交失败

出于某种原因,您的变更建议无法提交。请在几分钟内重试。感谢您抽出时间帮助我们提升 Unity 文档的质量。

关闭

取消

public int 最小单词索引化长度;

描述

最小被索引的词的大小。默认值为 2。

using System.Linq;
using UnityEditor;
using UnityEditor.Search;
using UnityEngine;

/// <summary>
/// The property minWordIndexationLength is used to prevent indexing too many small
/// variations of words. By default it is set to 2, meaning that one-letter variations
/// won't be indexed, but you can control
/// how many character word variations are indexed.
/// </summary>
static class Example_SearchIndexer_minWordIndexationLength
{
    [MenuItem("Examples/SearchIndexer/minWordIndexationLength")]
    public static void Run()
    {
        var si = new SearchIndexer()
        {
            // Search query will have to include at least the first 5 characters to return any results.
            minWordIndexationLength = 5,
            minQueryLength = 5
        };

        si.Start();
        var di = si.AddDocument("document1");
        si.AddWord("technologies", 0, di);
        si.Finish(() => OnIndexReady(si));
    }

    private static void OnIndexReady(SearchIndexer si)
    {
        Debug.Assert(si.Search("tech").Count() == 0, "tech should not return any match");
        Debug.Assert(si.Search("techno").Count() == 1, "No result were found");
    }
}