Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
FuzzySearch
Experimental: The available options and handling of results may change in the future.
Inherits: RefCounted < Object
Provides fuzzy string searching and matching capabilities.
Description
The fuzzy search algorithm is designed to find target strings which mostly match a query string while allowing for breaks, typos, and out of order matches.
var items := ["Potion of Healing", "Greater Health Potion", "Poison Vial"]
var fuzzy := FuzzySearch.new()
for result in fuzzy.search_all("health potion", items):
# Prints "Greater Health Potion", "Potion of Healing"
print(result.target)
string[] items = ["Potion of Healing", "Greater Health Potion", "Poison Vial"];
FuzzySearch fuzzy = new();
foreach (var result in fuzzy.SearchAll("health potion", items))
{
// Prints "Greater Health Potion", "Potion of Healing"
GD.Print(result.Target);
}
Properties
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods
search_all(query: String, targets: PackedStringArray) const |
Property Descriptions
Whether the query character casing should be matched exactly or not.
Minimum score for filtering results returned by search_all().
Biases the filtering cutoff score between the average score and max score. Value should be between 0 and 1.
bool filter_low_scores = true 🔗
If true, lower quality matches are not returned by search_all(). The default filtering behavior is tuned to keep exact matches and reject significantly broken up matches. Setting this to false can potentially improve results when searching a small number of items.
Maximum number of non-matched characters in the query before skipping a target as non-matching. This option is ignored if use_exact_tokens is true.
Maximum number of results which can be returned by search_all().
Number of leading characters to omit from matching. For example, this can be used to skip a common prefix such as res://.
bool use_exact_tokens = false 🔗
If true, only targets which contain each token as a non-overlapping substring are returned. Gaps and missed characters are not considered valid matches, but case_sensitive is still used.
Method Descriptions
FuzzySearchMatch search(query: String, target: String) const 🔗
Searches the target for query, returning a FuzzySearchMatch instance on success or null otherwise.
Array[FuzzySearchMatch] search_all(query: String, targets: PackedStringArray) const 🔗
Searches all of targets for query and returns up to the top max_results scoring values. The results are sorted by score in descending order. Low quality results are removed if filter_low_scores is true.