Search Algorithms

SearchMatch 是将 textpattern 匹配的接口。匹配结果保存在返回的值 SearchMatchResult 中。匹配结果包含有关匹配位置和匹配的总体得分的信息。

SearchMatch is an interface to match text with a pattern. Match results are in a returned value SearchMatchResult. Match result contains info about match positions and overall score of a match. fzf.

Implementations

FuzzyMatchV2Search

fzf FuzzyMatchV2Search 算法的移植。执行快速模糊搜索并且擅于快速查找路径。

Port of fzf FuzzyMatchV2Search algorithm. Does a fast fuzzy search and is good quickly finding paths.

ExactMatchNaive

fzf ExactMatchNaive 算法的移植。如果你知道要搜索的内容,则简单的精确匹配工作得更准确。

Port of fzf ExactMatchNaive algorithm. Simple exact match works more accurately if you know what to search.

SearchMatch

算法和默认语法隐藏在受包保护的类内,因为在我们知道 API 能够长期支持之前,我们不想完全开放这些类。你需要通过其内部构建器构建 SearchMatch

Algorithms and default syntax are hidden inside package protected classes as we don’t want to fully open these until we know API’s are good to go for longer support. You need to construct SearchMatch via its build-in builder.

Unresolved include directive in modules/ROOT/pages/appendices/techintro/searchalgorithm.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/SearchAlgorithmsSnippets.java[]

可以对 case sensitivity 进行配置,具体取决于 direction 搜索发生的位置或文本在搜索发生之前是否应 normilized。当不同的语言对相同类型的字符有细微差别时,归一化非常方便。

It’s possible to configure case sensitivity, on what direction search happens or if text should be normilized before search happens. Normalization is handy when different languages have sligh variation for same type of characters.

搜索算法根据下表所示的搜索语法选择。

Search algorithm is selected based on a search syntax shown in below table.

Table 1. Search syntax
Token Match type Description

hell

fuzzy-match

Items that match hello

’stuff`

exact-match

Items that include stuff

Examples

Unresolved include directive in modules/ROOT/pages/appendices/techintro/searchalgorithm.adoc - include::../../../../../src/test/java/org/springframework/shell/docs/SearchAlgorithmsSnippets.java[]