trigram search
String metric algorithm
≈ 2 min read
Names in other languages
- فارسیپیشنویس:جستجوی Trigram
- Englishtrigram search
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
Trigram search is a method of searching for text when the exact syntax or spelling of the target object is not precisely known or when queries may be regular expressions. It finds objects which have the most matches against three-character substrings (i.e. trigrams) of the search terms, which are generally near matches.
Two strings with many shared trigrams can be expected to be very similar. Trigrams also allow for efficiently creating search engine indexes for searches that are regular expressions or match the text inexactly. Indexes can significantly accelerate searches.
A threshold for number of trigram matches can be specified as a cutoff point, after a result is unmatched. Using trigrams for accelerating searches is a technique used in some systems for code searching, in situations in which queries that are regular expressions may be useful, in search engines such as Elasticsearch, as well as in databases such as PostgreSQL.
See also
Approximate string matching Google Code Search N-gram
Text derived from https://en.wikipedia.org/w/index.php?oldid=1354997049 under CC BY-SA 4.0; modifications have been made.