Fields and typos
Choose which fields a search reads, in which order, and how many typos it forgives.
A shopper's words are looked for in the fields their type lists, in priority order, and a long word is found even with a typo. Here is how the home store searches its products:
curl -s -H "Authorization: Bearer $key" $api/search-settings \
| jq -c '.types[] | select(.type == "product") | .fields.source, [.fields.fields[].field], .typos'"set"
["title","brand","keywords","attributes.color","attributes.material","attributes.upholstery","attributes.style","attributes.model_number","attributes.gtin","description"]
{"source":"built_in","enabled":true,"one_typo":5,"two_typos":9}A word found in an earlier field ranks a hit higher, so the title comes first. Each setting's source says where it comes from: set in types.json, derived from the catalog, or built_in, OrbSearch's default.
Reference: search · GET /api/v1/search-settings
Typos
A word of 5 letters or more finds what holds it with one typo, and from 9 letters with two. A typo is a letter added, left out or changed, or two neighbours swapped; one at the first letter counts as two. "Teppcih" swaps two letters of "Teppich" (rug), and the trace's rank step names the typo:
curl -s 'http://127.0.0.1:7800/v1/search?query=Teppcih&debug=1' \
| jq -r '.trace.steps[] | select(.step == "rank") | .sections[] | select(.type == "product")
| .hits[0] | .entity, (.why[] | select(.because.kind == "text") | .sentence)'product:TEPPICH-MARE
Found by every word of the query, with 1 typo (“teppcih” as “Teppich”), in title, description and words.words holds what the index adds, such as the titles of a product's categories. A shorter word finds only as written or by its start, so "Lnud" does not find the Lund sofa.
Identifiers exempt from typos
A part number one character off names another product, so the words of an attribute in no_typos are found only as written or by their start. Where a type leaves no_typos out, every index run derives it from the catalog, with a reason for each identifier the type searches:
curl -s -H "Authorization: Bearer $key" $api/search-settings \
| jq -c '.types[] | select(.type == "product") | .exempt | .source, (.open[] | {attribute, reason})'"derived"
{"attribute":"model_number","reason":{"by":"few","values":0}}
{"attribute":"gtin","reason":{"by":"few","values":0}}An identifier is exempt as unique when 90 % of at least 10 values belong to one product alone. Values products share, such as cross-reference numbers, stay open as shared, and too few to tell as few: the home store's catalog holds no model numbers or GTINs.
An exemption covers the attribute's own words; the same word in a title still finds with a typo.
Reference: no_typos
A word the search does not look for
When a product holds the shopper's word in a field the search skips, POST $api/preview/find says so, as the playground's Why isn't it here? does. The Fjord bed's finish is "Geölt" (oiled), but the product type does not search its finish:
curl -s -H "Authorization: Bearer $key" -H 'Content-Type: application/json' \
-d '{"request": {"query": "geölt"}, "entity": "product:BETT-FJORD"}' $api/preview/find \
| jq -c '.verdict.held[], .next[0]'{"word":"geolt","field":"attributes.finish","holds":"Geölt","why":"not_searched"}
{"step":"open_search_settings","type":"product"}held names the word as the engine reads it, the field that holds it and why: not_searched, or exempt_from_typos for an exempt attribute that holds it a typo away. The first next step opens the type's search settings.
Reference: held · POST /api/v1/preview/find
Change how a type is searched
Changes go into a draft, which you publish when it is right. Here the product type's words forgive a typo from 4 letters on.
Search → Fields & typos shows one type at a time, picked on top:
- Searched fields: drag a field by its handle, or press ↑ or ↓ on it. Add a field adds one the type could search.
- Typos: Find words with typos, One typo from and Two typos from. Set One typo from to 4 letters.
- Exempt from typos: Exempt an attribute adds one; the identifiers left Open to typos show with why.
Each card says Set here or Import's default, and Back to the default undoes a setting. The publish bar above says how the draft goes live, beside Publish. The Playground links here from a hit's typo reason and from Why isn't it here?.
Start a draft, then change the product type's typo lengths. typos replaces the setting whole, a setting left out stays, and null sets one back to its default:
draft=$(curl -s -X POST -H "Authorization: Bearer $key" -H 'Content-Type: application/x-ndjson' \
--data-binary @tests/fixtures/home/catalog.jsonl "$api/imports?name=catalog.jsonl" | jq -r .import.id)
version=$(curl -s -H "Authorization: Bearer $key" $api/imports/$draft/search-settings | jq -r .version)
jq -n --arg version "$version" '{version: $version, typos: {enabled: true, one_typo: 4, two_typos: 9}}' \
| curl -s -X PATCH -H "Authorization: Bearer $key" -H 'Content-Type: application/json' -d @- \
$api/imports/$draft/search-settings/product \
| jq -c '.settings.types[] | select(.type == "product") | .typos'{"source":"set","enabled":true,"one_typo":4,"two_typos":9}The answer is the draft's settings after the write, the typos now set. fields and exempt change the same way. Ask how the draft goes live, then publish it with POST $api/imports/$draft/publish, or discard it:
curl -s -H "Authorization: Bearer $key" $api/imports/$draft/publication | jq -r .course.sentence
curl -s -X DELETE -H "Authorization: Bearer $key" $api/imports/$draft | jq -r .stateGoes live within moments: types.json changed only settings the engine applies without reindexing.
discardedReference: PATCH .../search-settings/{type} · GET .../search-settings
How it goes live
The order of the fields and the typos are settings the engine takes at once. The rest changes what the index holds for every product:
| Change | Goes live |
|---|---|
| Order of the searched fields | Within moments, as settings |
| Typo settings | Within moments, as settings |
| Which fields are searched | By a rebuild |
| Which attributes are exempt | By a rebuild |
The shop answers with what is live while a rebuild runs (Releases). A preview searches the live index, so a draft's typo settings show only once it is live.
Next
- Synonyms: words that find each other, such as "couch" and "sofa".
- How search understands a query: how the words left as text are matched.
- Releases: draft, preview, publish and roll back.