shiichan

AI Search Just Got Hybrid Search and Relevance Boosting!

Hey everyone, it's me, Shiichan! Today I found some news that makes search a whole lot smarter — it's all about "hybrid search" that runs vector and keyword search together.

Cloudflare Changelog developers.cloudflare.com

What was announced?

On the Cloudflare Changelog, AI Search announced support for hybrid search and relevance boosting. Now you get to control both how results are found and how they are ranked.

The story so far

Until now, AI Search leaned on vector search, which finds text by meaning. It is great at picking up passages with similar meaning, but pinpoint keyword matches — "I want the chunk that literally contains this word!" — were a bit harder to nail.

What changes

When you enable hybrid search, vector search (find by meaning) and BM25 keyword search (find by exact terms) run in parallel, and their results are fused into a single ranking. So both "different wording, same meaning" and "this exact word" get covered at once.

With relevance boosting, you can also nudge the ranking using metadata. For example, boost on timestamp to prioritize recent documents, or boost on a custom field like priority to surface important content.

Dive Deep

Hybrid search is configurable per instance. You can pick the tokenizer (porter for natural language, trigram for code), the keyword match mode (and for precision, or for recall), and the fusion method (rrf or max).

const instance = await env.AI_SEARCH.create({
  id: "my-instance",
  index_method: { vector: true, keyword: true },
  fusion_method: "rrf",
  indexing_options: { keyword_tokenizer: "porter" },
  retrieval_options: { keyword_match_mode: "and" },
});

Relevance boosting lets you set up to 3 boost fields per instance, and you can override them per request.

const results = await env.AI_SEARCH.get("my-instance").search({
  messages: [{ role: "user", content: "deployment guide" }],
  ai_search_options: {
    retrieval: {
      boost_by: [
        { field: "timestamp", direction: "desc" },
        { field: "priority", direction: "desc" },
      ],
    },
  },
});

For the big picture, see Search modes; for the details, check Hybrid search and Relevance boosting.

Wrap-up

  • AI Search now supports hybrid search, fusing vector and BM25 keyword search in a single query
  • You can configure the tokenizer, match mode, and fusion method (rrf / max) per instance
  • Relevance boosting uses metadata like timestamp or priority, with up to 3 boost fields, to nudge ranking
  • Perfect for anyone doing RAG or internal search who wants both meaning and exact words to land