All Products
Search
Document Center

OpenSearch:Fuzzy searches

Last Updated:Jun 25, 2026

When search intent is broad or a user's input only partially matches the stored content, exact-term matching fails to return relevant results. Fuzzy searches address this by retrieving documents where the query appears as a substring, pinyin representation, prefix, suffix, or consecutive character sequence within the field value.

Important

Fuzzy searches apply only to fields of the SHORT_TEXT type. Before using any fuzzy search type, set the target field to SHORT_TEXT and assign an analyzer for fuzzy searches when creating your application.

Warning

Fuzzy searches can return a large number of unintended results when the search intent is ambiguous. Use fuzzy searches based on your specific business requirements.

Fuzzy search types at a glance

Search type When to use Syntax example Requires double quotes
Pinyin search Match Chinese text using pinyin input "kfss", "kaifang" Yes
Prefix search Match content starting with a specific string "^138" Yes
Suffix search Match content ending with a specific string "9527$" Yes
Phrase search Match an exact consecutive sequence of letters and digits "OpenSearch" Yes
Single character/word search Broaden recall by matching individual characters or words 'fang', 'o' No (single quotes)

In most cases, enclose search queries in single quotation marks (' '). Double quotation marks (" ") are required only for pinyin, prefix, suffix, and phrase searches.

Prerequisites

Before using fuzzy searches, ensure that you have:

  • An OpenSearch application with at least one field set to the SHORT_TEXT type

  • An analyzer for fuzzy searches assigned to that field when creating the application

Pinyin search

Pinyin search retrieves Chinese-language documents using pinyin input — either full spellings or abbreviations formed from the initial letters of each syllable.

Example

The document contains: kaifang sousuo

Query type Search queries
Full pinyin spelling "kai", "kaifang", "sousuo", "kaifangsousuo"
Pinyin abbreviation "k", "kf", "ss", "kfss"

All eight queries above retrieve the document.

Usage notes

  • Enclose pinyin search queries in double quotation marks (" ").

  • When using pinyin abbreviations, the matched Chinese characters are expected to appear consecutively in retrieved documents. For example, "kfss" expects kaifang sousuo to appear as a consecutive string. Double quotation marks enforce this expectation.

Prefix search

Prefix search retrieves documents where a field value begins with the specified string.

Note

Prefix searches do not support Chinese characters. Use letters, digits, or pinyin only.

Example

To retrieve mobile numbers starting with 138, use the query clause: query=default:"^138"

The caret (^) is the prefix identifier. Enclose the query in double quotation marks (" ").

Suffix search

Suffix search retrieves documents where a field value ends with the specified string.

Note

Suffix searches do not support Chinese characters. Use letters, digits, or pinyin only.

Example

To retrieve mobile numbers ending with 9527, use the query clause: query=default:"9527$"

The dollar sign ($) is the suffix identifier. Enclose the query in double quotation marks (" ").

Phrase search

Phrase search retrieves only documents that contain the exact consecutive sequence of letters and digits specified in the query.

Note

Phrase searches improve result accuracy but reduce the number of retrieved documents and consume more resources. Use the general-purpose Chinese text analyzer for phrase searches.

Examples

# Query clause 1: query=default:"OpenSearch"
Retrieves documents containing "xxxOpenSearchxxx".
Does NOT retrieve documents containing "xxxSearchOpenxxx".

# Query clause 2: query=default:"HUAWEIP"
Does NOT retrieve documents containing "HUAWEIP20".
"HUAWEIP20" is not a consecutive match for "HUAWEIP" because "20" extends the string.
To retrieve "HUAWEIP20", use single quotation marks: query=default:'HUAWEIP'

Single character/word search

Single character or word searches broaden recall by matching individual characters or words anywhere in the document.

Note

Single character/word searches return more documents but results may be less precise. Use this type when broad recall matters more than precision.

Example

Document: kaifang sousuo open search

Query clause Result
query=default:'fang' Retrieves the document
query=default:'o' Retrieves the document

Limitations

The following limitations apply to fuzzy searches. Where relevant, limitations are also noted inline in each search type section above.

Limitation Details
Field type The analyzer for fuzzy searches applies only to SHORT_TEXT fields
Field length After punctuation is filtered out, up to 100 bytes of a SHORT_TEXT field value are retained; the rest is discarded
Punctuation Punctuation marks in SHORT_TEXT field values are filtered out during indexing
Chinese characters in prefix/suffix Prefix and suffix searches do not support Chinese characters; use letters, digits, or pinyin
Query analysis The query analysis feature is not available for indexes built on SHORT_TEXT fields
Highlighting Letters, digits, and pinyin cannot be highlighted in red in search result summaries
Full-width characters If only the fuzzy search analyzer is used, full-width characters are converted to half-width characters in search result summaries. To prevent this, use an analyzer for Chinese to create an index
Drop-down suggestions Drop-down suggestions models can be built on SHORT_TEXT fields

Default sort order

Fuzzy search results are sorted by the position of the matched term within the field value. A document where the match appears earlier ranks higher.

Example: Searching "kfss" returns:

  • doc1 (contains kaifang sousuo) — ranked first

  • doc2 (contains xihuan shiyong kaifang sousuo) — ranked lower