How search works

The mental model behind queries, scoring and ranking.

Searching an index goes through five stages. Knowing them is enough to debug 99% of "why isn't this document showing up?" questions.

# 1. Query parsing

q is tokenised. Stop words (configured per index) are removed. prefix=true (the default) marks the last token for prefix matching, so typing son matches Sony.

# 2. Synonym expansion

Each token is expanded through your synonym map. A search for placute frana becomes (placute|pastile) frana internally.

# 3. Filtering

filter_by runs first. Filters narrow the candidate pool before scoring, so they don't cost ranking time. Use them aggressively.

# 4. Engine retrieval + text-match scoring

The engine runs the parsed query against the fields in query_by with the configured query_by_weights. Typo tolerance is applied per the index's typo_config. Each surviving document gets a base text_match score.

# 5. Skryx relevance bonuses + ranking rules

On top of the engine's text_match, Skryx adds relevance bonuses (prefix hit, SKU exact match, brand match, position-in-title) and applies your ranking rules (boost / pin / bury / hide).

The final list is sorted by:

  1. pin rules (in declared order).
  2. Final score (text_match + bonuses + rule weights).
  3. default_sorting_field if you set one (tie-breaker).

# Where AI Query Understanding fits

If enabled and the heuristic decides the query is worth enhancing, AI rewriting happens before stage 1 — the engine sees the rewritten query. The original is returned to you in ai_context for UI purposes.

See AI features for the full flow.

esc