Find words in order
The language tabs use earlier client interfaces. Check SDK versions and connection setup before running them.
Match adjacent words in query order after the field’s analyzer has processed them.
Before you run it: Phrase mode is not fuzzy matching. Analysis can remove punctuation and change case.
The indexed sample contains the adjacent words noise cancellation, so p001 should match. An analyzer is the rule that splits and normalizes text before comparison. Phrase matching follows those processed words, not the original punctuation byte for byte.
- Index token positionsLoad the sample text containing noise cancellation.
- Search the phraseRequire those processed words next to each other.
- Read matching IDsOpen the documents that preserve the requested word order.
Follow the example
- Index the sample text.
- Choose a phrase.
- Set mode: phrase.
- Inspect the matching documents.
Run the request
First index the sample text. Use the same table and field in the search request; storing a row alone does not create its search entry.
curl -G "https://$OC_HOST/v1/tenants/$OC_TENANT/fts/shop.products/description" \
-H "Authorization: Bearer $OC_TOKEN" \
--data-urlencode "q=noise cancellation" \
--data-urlencode "mode=phrase"Check the result
The result contains IDs whose analyzed words contain the phrase.
["p001"]Same shape as boolean: a bare array of doc_id strings, no wrapper, no scores. Phrase mode just narrows which docs qualify.
Understand the behavior
- The query is tokenised the same way as the indexed text.
- The engine pulls posting lists for each token along with token positions inside each document.
- A doc matches only if the positions are consecutive: position(ti+1) = position(ti) + 1 for every adjacent token pair.
Important limits and checks
- Expecting stemming to bridge word forms. The API analyzer is Unicode-tokenize + lowercase only - it does not stem.
q=noise cancelwill not match a doc that says "noise cancellation"; the literal tokencancellationmust be present. - Punctuation between tokens. Most analysers strip punctuation -
"noise, cancellation"in the source text still phrase-matchesq=noise cancellation. - Expecting fuzzy behaviour. Phrase is strict - one typo and the phrase doesn't match. Use BM25 with
fuzzy=1if you need typo tolerance.