<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>SeekStorm</title>
    <description>sub-millisecond lexical search</description>
    <link>https://seekstorm.com/blog/</link>
    <atom:link href="https://seekstorm.com/blog/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Tue, 13 Oct 2026 08:31:54 +0000</pubDate>
    <lastBuildDate>Tue, 13 Oct 2026 08:31:54 +0000</lastBuildDate>
    <generator>Jekyll v3.8.5</generator>
    
      <item>
        <title>Introducing the SeekStorm MCP server</title>
        <description>&lt;p&gt;&lt;strong&gt;Connect AI applications to SeekStorm through the Model Context Protocol (MCP), with no separate &lt;code class=&quot;highlighter-rouge&quot;&gt;seekstorm_server&lt;/code&gt; process required.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AI agents are only as good as the tools they can reach, and for most agents the most important tool is &lt;em&gt;search&lt;/em&gt;. With &lt;strong&gt;SeekStorm v3.4.0&lt;/strong&gt; we’re shipping a new &lt;strong&gt;SeekStorm MCP server&lt;/strong&gt;: a local, single-binary MCP server that embeds the SeekStorm search library directly, manages its own index, and talks to your AI client over &lt;strong&gt;stdio&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Point Claude, Cursor, or any other MCP-compatible client at it, and your agent gets fast lexical, vector, and hybrid search over your own documents in a few minutes.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;whats-included&quot;&gt;What’s included&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;🔍 &lt;strong&gt;Lexical, vector &amp;amp; hybrid search&lt;/strong&gt;: combine full-text (BM25) and semantic retrieval in one index.&lt;/li&gt;
  &lt;li&gt;⚙️ &lt;strong&gt;Advanced search features&lt;/strong&gt;: filters, facets, sorting, and highlighting.&lt;/li&gt;
  &lt;li&gt;🗂️ &lt;strong&gt;Flexible indexing&lt;/strong&gt;: configurable schemas and index settings, plus document indexing, updating, deletion, retrieval, and iteration.&lt;/li&gt;
  &lt;li&gt;📥 &lt;strong&gt;Multiple ingestion formats&lt;/strong&gt;: JSON, NDJSON, and PDF indexing.&lt;/li&gt;
  &lt;li&gt;✅ &lt;strong&gt;Tested&lt;/strong&gt;: unit tests, stdio integration tests, and MCP contract tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of it is powered by SeekStorm’s high-performance search engine, written in Rust.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;ai-agents-rag-and-mcp-what-they-are-and-how-they-fit-together&quot;&gt;AI agents, RAG, and MCP: what they are and how they fit together&lt;/h2&gt;

&lt;p&gt;Three terms show up together constantly, and it’s easy to blur them. Here is what each one actually is.&lt;/p&gt;

&lt;h3 id=&quot;what-is-an-ai-agent&quot;&gt;What is an AI agent?&lt;/h3&gt;

&lt;p&gt;An AI agent is a large language model (LLM) wired up with &lt;strong&gt;tools and a loop&lt;/strong&gt;. Instead of producing one reply and stopping, an agent decides which action to take next, calls a tool, reads the result, and decides again, repeating until the task is done.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Reasons&lt;/strong&gt;: plans the next step from the goal and what it has learned so far.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Acts&lt;/strong&gt;: calls a tool (search, a database, an API, code execution) to gather information or make a change.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Observes &amp;amp; repeats&lt;/strong&gt;: reads the tool’s output, updates its plan, and loops until the task is complete.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two things set agents apart from a plain chatbot: they can take multiple steps without a person prompting each one, and every step is only as good as the tools available. A coding agent is only as good as its access to the repo and a shell. A research agent is only as good as its access to accurate, up-to-date information, which is where retrieval and search come in.&lt;/p&gt;

&lt;h3 id=&quot;what-is-rag-retrieval-augmented-generation&quot;&gt;What is RAG (Retrieval-Augmented Generation)?&lt;/h3&gt;

&lt;p&gt;An LLM only knows what was in its training data, up to its cutoff date. It has no built-in access to your documents, your product catalog, or this morning’s news. &lt;strong&gt;RAG&lt;/strong&gt; closes that gap. Before the model generates an answer, a retrieval step searches an external knowledge base for the passages most relevant to the question and hands them to the model as context.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Query&lt;/strong&gt;: the user or agent asks a question.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Retrieve&lt;/strong&gt;: a search engine finds the relevant passages.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Augment&lt;/strong&gt;: the passages are added to the model’s context.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Generate&lt;/strong&gt;: the model answers, grounded in that text.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The quality of a RAG system is capped by the quality of its retrieval step. If the search misses the relevant document, or buries it below irrelevant ones, the model never sees it, and no amount of prompting fixes that afterwards. RAG is fundamentally a search problem wearing an AI hat: it needs an engine that finds both the right &lt;em&gt;keywords&lt;/em&gt; (lexical / BM25) and the right &lt;em&gt;meaning&lt;/em&gt; (vector / semantic), fast enough to sit in an interactive loop.&lt;/p&gt;

&lt;h3 id=&quot;what-is-mcp-model-context-protocol&quot;&gt;What is MCP (Model Context Protocol)?&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://modelcontextprotocol.io/&quot;&gt;MCP&lt;/a&gt; is an open standard for connecting AI applications (chat clients, IDEs, coding agents) to external tools and data sources through &lt;strong&gt;one common protocol&lt;/strong&gt; instead of a custom integration per pair.&lt;/p&gt;

&lt;p&gt;Before MCP, giving an agent access to your search index, your database, and your ticketing system meant writing and maintaining a bespoke connector for each model and each tool. MCP defines a single client/server interface: any MCP-compatible client can talk to any MCP server without either side knowing the other’s internals in advance.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;MCP server&lt;/strong&gt;: exposes a tool or data source, such as a search index, as a set of callable, discoverable capabilities.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;MCP client&lt;/strong&gt;: lives inside the AI application or agent, discovers available servers, and calls their tools on the model’s behalf.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short: &lt;strong&gt;the agent is the actor, RAG is one of the things it can do, and MCP is the wiring&lt;/strong&gt; that lets it do so against real, external systems without one-off integration code.&lt;/p&gt;

&lt;h3 id=&quot;how-they-connect&quot;&gt;How they connect&lt;/h3&gt;

&lt;p&gt;Put together, the three layer on top of each other:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;The &lt;strong&gt;agent&lt;/strong&gt; is given a goal and decides, step by step, that it needs more information than it already has in its context window.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;MCP&lt;/strong&gt; is how it reaches that information: it calls a search tool exposed by an MCP server, using the same protocol regardless of which search engine, database, or API sits behind it.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;RAG&lt;/strong&gt; is what happens with the result: the retrieved passages are folded into the model’s context, so the next reasoning step and the final answer are grounded in real data instead of training-time memory.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An agent can run this cycle many times within a single task, often issuing several retrieval calls in parallel or in quick succession. That’s a very different load pattern from a person typing one query into a search box: it’s bursty, machine-speed, and unforgiving of slow or shallow retrieval.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;why-seekstorm-as-the-retrieval-layer&quot;&gt;Why SeekStorm as the retrieval layer&lt;/h2&gt;

&lt;p&gt;SeekStorm is built to be the retrieval layer underneath agents, RAG pipelines, and MCP, not retrofitted after the fact.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Hybrid search, one index.&lt;/strong&gt; Lexical (BM25) and vector search run natively over the same index. There is no separate vector database to keep in sync, and you get exact keyword matches and semantic matches combined.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Real-time indexing.&lt;/strong&gt; Documents are searchable the moment they’re indexed, so an agent’s retrieved context never lags behind the underlying data.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Machine-speed, parallel-ready.&lt;/strong&gt; Built in Rust for the request patterns agents generate: many queries, issued in parallel, with low and predictable latency.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;One portable index.&lt;/strong&gt; The same index can back a human-facing search box &lt;em&gt;and&lt;/em&gt; serve as the retrieval tool an agent calls through MCP.&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;how-the-seekstorm-mcp-server-works&quot;&gt;How the SeekStorm MCP server works&lt;/h2&gt;

&lt;p&gt;The server runs as a &lt;strong&gt;child process over MCP stdio&lt;/strong&gt;, the same way most local MCP servers work today. It embeds SeekStorm directly and owns its local index: single binary, zero network hop, no &lt;code class=&quot;highlighter-rouge&quot;&gt;seekstorm_server&lt;/code&gt; process needed.&lt;/p&gt;

&lt;p&gt;That makes it a natural fit for agentic search over local content: a coding agent indexing a repository, or a RAG pipeline indexing a knowledge base on the same machine.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; the MCP server currently implements &lt;strong&gt;embedded mode&lt;/strong&gt; only. It does not yet connect to a remote SeekStorm server.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;quickstart&quot;&gt;Quickstart&lt;/h3&gt;

&lt;p&gt;Build from the workspace root:&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;cargo build --release -p seekstorm_mcp_server
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Add the server to your MCP client configuration, replacing the executable path with the location of your built binary:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;mcpServers&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;seekstorm&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;command&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;C:/path/to/seekstorm_mcp_server.exe&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;env&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;SEEKSTORM_INDEX_PATH&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;C:/Users/me/seekstorm-index&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The server opens the index at &lt;code class=&quot;highlighter-rouge&quot;&gt;SEEKSTORM_INDEX_PATH&lt;/code&gt; if it exists. Otherwise it creates one there with a small default schema containing &lt;code class=&quot;highlighter-rouge&quot;&gt;title&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;body&lt;/code&gt;, and &lt;code class=&quot;highlighter-rouge&quot;&gt;path&lt;/code&gt; text fields. The index is committed when the MCP process exits.&lt;/p&gt;

&lt;p&gt;During development you can also launch it directly from the workspace:&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;$env&lt;/span&gt;:SEEKSTORM_INDEX_PATH &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PWD&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/seekstorm_index&quot;&lt;/span&gt;
cargo run -p seekstorm_mcp_server
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;MCP clients speak the stdio protocol, so the server must never write regular output to stdout.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;try-it-without-an-agent&quot;&gt;Try it without an agent&lt;/h3&gt;

&lt;p&gt;An MCP client such as &lt;a href=&quot;https://github.com/conikeec/mcp-probe&quot;&gt;MCP Probe&lt;/a&gt; lets you talk to the server directly:&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;$env&lt;/span&gt;:SEEKSTORM_INDEX_PATH&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;seekstorm_index&quot;&lt;/span&gt;;
.\mcp-probe debug --stdio &lt;span class=&quot;s2&quot;&gt;&quot;seekstorm_mcp_server.exe&quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;custom-schemas-and-index-settings&quot;&gt;Custom schemas and index settings&lt;/h3&gt;

&lt;p&gt;To create an index with a different schema or vector settings at startup, set &lt;code class=&quot;highlighter-rouge&quot;&gt;SEEKSTORM_INDEX_CONFIG&lt;/code&gt; to a JSON file containing a SeekStorm &lt;code class=&quot;highlighter-rouge&quot;&gt;CreateIndexRequest&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;index_name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;project_docs&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;schema&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;field&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;field_type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Text&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;store&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;index_lexical&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;boost&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;field&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;body&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;field_type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Text&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;store&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;index_lexical&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;longest&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;field&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;field_type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Text&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;store&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;index_lexical&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;similarity&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Bm25f&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tokenizer&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;UnicodeAlphanumericFolded&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The request uses the same schema and index-setting types as the SeekStorm library and REST client, including synonyms, spelling correction, query completion, vector inference, and clustering. For an already-running process, use the &lt;code class=&quot;highlighter-rouge&quot;&gt;create_index&lt;/code&gt; tool with an &lt;code class=&quot;highlighter-rouge&quot;&gt;index_path&lt;/code&gt; and a &lt;code class=&quot;highlighter-rouge&quot;&gt;config&lt;/code&gt; object, or &lt;code class=&quot;highlighter-rouge&quot;&gt;open_index&lt;/code&gt; to switch to an existing local index. Switching indexes commits the active one first.&lt;/p&gt;

&lt;h3 id=&quot;the-tools-your-agent-gets&quot;&gt;The tools your agent gets&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Area&lt;/th&gt;
      &lt;th&gt;Tools&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Index management&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;create_index&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;open_index&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;get_index_info&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;clear_index&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;commit&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Indexing&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;index_document&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;index_documents&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;update_document&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;update_documents&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Retrieval&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;search&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;get_document&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;document_iterator&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Deletion&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;delete_document&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;delete_documents&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;delete_documents_by_query&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ingestion &amp;amp; files&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;ingest_json&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;index_pdf_file&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;get_file&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Documents are arbitrary JSON objects whose fields must match the active index schema. &lt;code class=&quot;highlighter-rouge&quot;&gt;ingest_json&lt;/code&gt; streams JSON arrays, NDJSON, and concatenated JSON documents. &lt;code class=&quot;highlighter-rouge&quot;&gt;index_pdf_file&lt;/code&gt; extracts text from a local PDF (it requires an available Pdfium library), and &lt;code class=&quot;highlighter-rouge&quot;&gt;get_file&lt;/code&gt; returns the associated file bytes as base64 text.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;delete_documents_by_query&lt;/code&gt; uses &lt;code class=&quot;highlighter-rouge&quot;&gt;length&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;offset&lt;/code&gt; to bound and page through matching documents before deletion, so it’s good practice to search first and verify the intended matches.&lt;/p&gt;

&lt;h3 id=&quot;searching-lexical-vector-hybrid&quot;&gt;Searching: lexical, vector, hybrid&lt;/h3&gt;

&lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;search&lt;/code&gt; tool accepts a &lt;code class=&quot;highlighter-rouge&quot;&gt;query&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;length&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;offset&lt;/code&gt;, and &lt;code class=&quot;highlighter-rouge&quot;&gt;search_mode&lt;/code&gt; enum (&lt;code class=&quot;highlighter-rouge&quot;&gt;Lexical&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;Vector&lt;/code&gt;, or &lt;code class=&quot;highlighter-rouge&quot;&gt;Hybrid&lt;/code&gt;). It also supports SeekStorm query types and rewriting, real-time search, field selection, facet filters and facets, sorting, and highlighting, ANN settings, and similarity thresholds.&lt;/p&gt;

&lt;p&gt;A lexical search:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;query&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;indexing pipeline&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;mode&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Lexical&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;length&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;offset&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;field_filter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;body&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A vector search against a 3-dimensional vector index:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;query&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;related documents&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;search_mode&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Vector&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;similarity_threshold&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ann_mode&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;All&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;query_vector&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;F32&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;-0.03&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.88&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;length&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For vector or hybrid search, provide &lt;code class=&quot;highlighter-rouge&quot;&gt;query_vector&lt;/code&gt; as a SeekStorm &lt;code class=&quot;highlighter-rouge&quot;&gt;Embedding&lt;/code&gt; enum (&lt;code class=&quot;highlighter-rouge&quot;&gt;{&quot;F32&quot;: [...]}&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;{&quot;I8&quot;: [...]}&lt;/code&gt;), unless the index is configured with an internal inference model. Explicit vectors must match the index dimensions. Vector search needs vector-indexed fields in the schema; hybrid search can combine lexical fields and vectors. &lt;code class=&quot;highlighter-rouge&quot;&gt;Vector&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;Hybrid&lt;/code&gt; search modes carry their own &lt;code class=&quot;highlighter-rouge&quot;&gt;similarity_threshold&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;ann_mode&lt;/code&gt; fields.&lt;/p&gt;

&lt;p&gt;Facet definitions, filters, sort definitions, highlights, query rewriting, and enum settings are passed in their SeekStorm serialized JSON forms. Schema and index settings are fixed when an index is created; changing them means creating a new index and reindexing.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;try-it-with-your-own-agent&quot;&gt;Try it with your own agent&lt;/h2&gt;

&lt;p&gt;Run the MCP server with a local index for agentic search over your own docs or repo, and your agent gets real, grounded retrieval in minutes. Run the test suite from the workspace root with:&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;cargo &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; -p seekstorm_mcp_server
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Explore the release:&lt;/strong&gt; &lt;a href=&quot;https://github.com/SeekStorm/SeekStorm/releases/tag/v3.4.0&quot;&gt;SeekStorm v3.4.0 on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learn more:&lt;/strong&gt; &lt;a href=&quot;https://seekstorm.com/ai_agent_rag_mcp&quot;&gt;AI agents, RAG, and MCP explained&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;em&gt;#SeekStorm #MCP #ModelContextProtocol #Rust #AI #VectorSearch #OpenSource&lt;/em&gt;&lt;/p&gt;
</description>
        <pubDate>Mon, 12 Oct 2026 00:00:00 +0000</pubDate>
        <link>https://seekstorm.com/blog/seekstorm-mcp-server/</link>
        <guid isPermaLink="true">https://seekstorm.com/blog/seekstorm-mcp-server/</guid>
        
        
        <category>search</category>
        
        <category>AI</category>
        
        <category>agents</category>
        
        <category>RAG</category>
        
        <category>MCP</category>
        
        <category>rust</category>
        
        <category>oss</category>
        
      </item>
    
      <item>
        <title>symspell_rs v7 - 3x faster lookup, 40% less memory consumption, 11x faster Damerau-Levenshtein edit distance</title>
        <description>&lt;p&gt;&lt;strong&gt;symspell_rs v7&lt;/strong&gt; introduces both significant &lt;strong&gt;implementation changes to SymSpell&lt;/strong&gt; as well as &lt;strong&gt;algorithmic changes to the Damerau-Levenshtein calculation&lt;/strong&gt; between v6.8.4 vs. v7.0.1.&lt;br /&gt;
The resulting performance improvements are measured with the &lt;strong&gt;new benchmark suite&lt;/strong&gt; and discussed below.&lt;/p&gt;

&lt;h2 id=&quot;changes&quot;&gt;Changes&lt;/h2&gt;

&lt;h3 id=&quot;improved-damerau-levenshtein-calculation-optimal-string-alignment-osa-variant&quot;&gt;Improved Damerau-Levenshtein calculation, optimal string alignment (OSA) variant&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Optimized SymSpell v7 &lt;code class=&quot;highlighter-rouge&quot;&gt;damerau_levenshtein_osa&lt;/code&gt; by using &lt;strong&gt;bit-parallel OSA (&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S157086670400053X/pdf&quot;&gt;Hyyrö 2003&lt;/a&gt;)&lt;/strong&gt;, making it &lt;strong&gt;11x faster&lt;/strong&gt; than SymSpell v6.8.4 &lt;code class=&quot;highlighter-rouge&quot;&gt;damerau_levenshtein_osa&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Optimized SymSpell v7 &lt;code class=&quot;highlighter-rouge&quot;&gt;damerau_levenshtein_osa_fallback&lt;/code&gt; by using the &lt;strong&gt;multi-word block version&lt;/strong&gt; of the &lt;strong&gt;bit-parallel OSA (&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S157086670400053X/pdf&quot;&gt;Hyyrö 2003&lt;/a&gt;)&lt;/strong&gt;, to cover any length., making it &lt;strong&gt;7x faster&lt;/strong&gt; than than SymSpell v6.8.4 &lt;code class=&quot;highlighter-rouge&quot;&gt;damerau_levenshtein_osa&lt;/code&gt; for terms &amp;gt; 64 chars.&lt;/li&gt;
  &lt;li&gt;Exposed &lt;code class=&quot;highlighter-rouge&quot;&gt;damerau_levenshtein_osa&lt;/code&gt; as a public method for standalone use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;improved-symspell-implementation-internal-storage-allocation-free-shared-term-table-lightweight-hasher&quot;&gt;Improved SymSpell implementation: internal storage, allocation free, shared term table, lightweight hasher&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Internal storage: &lt;code class=&quot;highlighter-rouge&quot;&gt;words&lt;/code&gt; now maps terms to ids, and counts live in a new term table. Serialized dictionaries from previous versions (&lt;code class=&quot;highlighter-rouge&quot;&gt;serde&lt;/code&gt; feature) are not compatible.&lt;/li&gt;
  &lt;li&gt;The derived &lt;code class=&quot;highlighter-rouge&quot;&gt;PartialEq&lt;/code&gt; on &lt;code class=&quot;highlighter-rouge&quot;&gt;SymSpell&lt;/code&gt; compares term ids, so dictionaries with the same content but a different insertion order compare unequal.&lt;/li&gt;
  &lt;li&gt;ASCII input now takes an allocation-free fast path: stack-based candidates, borrowed hits, and &lt;code class=&quot;highlighter-rouge&quot;&gt;Suggestion&lt;/code&gt; strings created only for the returned results (after sort and &lt;code class=&quot;highlighter-rouge&quot;&gt;max_results&lt;/code&gt;). Non-ASCII input uses a char-based path that shares the same verification code.&lt;/li&gt;
  &lt;li&gt;Delete buckets store compact 8-byte entries (term id, length, ASCII flag) that refer to a shared term table, instead of a heap copy of the term per delete. This lowers memory use and removes pointer chasing.&lt;/li&gt;
  &lt;li&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;deletes&lt;/code&gt; map uses a lightweight hasher, since its keys are already 32-bit hashes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;verbose-benchmark-setup&quot;&gt;Verbose Benchmark setup&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Benchmark harness: &lt;a href=&quot;https://github.com/nvzqz/divan&quot;&gt;divan&lt;/a&gt; with a tracking global allocator. Results below are the figures printed to stderr by the benchmark.&lt;/li&gt;
  &lt;li&gt;81 lookup experiments per version: English frequency dictionaries with 30k, 82k and 500k entries × &lt;code class=&quot;highlighter-rouge&quot;&gt;prefix_length&lt;/code&gt; 5, 6, 7 × maximum edit distance 1, 2, 3 × &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity&lt;/code&gt; Top, Closest, All. The dictionary is rebuilt for each maximum edit distance (maximum dictionary edit distance = maximum edit distance), which gives 27 dictionary builds per version.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Average latency&lt;/strong&gt; = average time per &lt;code class=&quot;highlighter-rouge&quot;&gt;lookup()&lt;/code&gt; call. &lt;strong&gt;Speedup&lt;/strong&gt; = latency of v6.8.4 ÷ latency of current (higher is better).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Build time&lt;/strong&gt; = time to build the dictionary. &lt;strong&gt;Resident memory&lt;/strong&gt; = resident memory after the build. &lt;strong&gt;Peak memory&lt;/strong&gt; = maximum memory consumption during the build.&lt;/li&gt;
  &lt;li&gt;Charts use a logarithmic y-axis where values span orders of magnitude (latency, build memory across dictionary sizes).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Verbose benchmark&lt;/strong&gt; based on &lt;a href=&quot;https://github.com/nvzqz/divan&quot;&gt;divan&lt;/a&gt;: &lt;code class=&quot;highlighter-rouge&quot;&gt;cargo bench --bench verbose  --features gxhash&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;basic-benchmark-setup&quot;&gt;Basic benchmark setup&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Lookup latency experiments (162 in total): the 30k, 82k and 500k English frequency dictionaries × &lt;code class=&quot;highlighter-rouge&quot;&gt;prefix_length&lt;/code&gt; 5, 6, 7 × maximum edit distance 1, 2, 3 × &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity&lt;/code&gt; Top, Closest, All × {this version, &lt;a href=&quot;https://crates.io/crates/symspell_rs/6.8.4&quot;&gt;symspell_rs 6.8.4&lt;/a&gt;}.&lt;/li&gt;
  &lt;li&gt;Load dictionary time experiments (27 in total): the 30k, 82k and 500k English frequency dictionaries × &lt;code class=&quot;highlighter-rouge&quot;&gt;prefix_length&lt;/code&gt; 5, 6, 7 × maximum edit distance 1, 2, 3&lt;/li&gt;
  &lt;li&gt;Damerau-Levenshtein OSA latency experiments (6 in total): maximum edit distance 1, 2, 3 x bit-parallel OSA, multi-word block bit-parallel OSA&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Basic benchmark&lt;/strong&gt;: &lt;code class=&quot;highlighter-rouge&quot;&gt;cargo bench --bench basic --features gxhash&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;test-data&quot;&gt;Test data&lt;/h3&gt;

&lt;h4 id=&quot;noisy_query_en_1000txt&quot;&gt;noisy_query_en_1000.txt&lt;/h4&gt;

&lt;p&gt;For the query we use the first 1000 unique words from Norvig’s text corpus &lt;a href=&quot;http://norvig.com/big.txt&quot;&gt;big.txt&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For each word a random number of edits in the range 0..Min(word.length/2 , 4) is chosen. For each edit a random type of edit (delete, insert random char, replace with random char, switch adjacent chars) is applied at a random position within the word. After the edits no duplicates and words with length&amp;lt;2 are allowed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;frequency_dictionary_en_30_000.txt&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are the 29,159 unique words from Norvig’s text corpus &lt;a href=&quot;http://norvig.com/big.txt&quot;&gt;big.txt&lt;/a&gt;, together with their frequency in that corpus.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;frequency_dictionary_en_82_765.txt&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The frequency_dictionary_en_82_765.txt was created by intersecting the two lists mentioned below. By reciprocally filtering only those words which appear in both lists are used. Additional filters were applied and the resulting list truncated to ≈ 80,000 most frequent words.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://storage.googleapis.com/books/ngrams/books/datasetsv2.html&quot;&gt;Google Books Ngram data&lt;/a&gt; &lt;a href=&quot;https://creativecommons.org/licenses/by/3.0/&quot;&gt;(License)&lt;/a&gt; : Provides representative word frequencies&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://wordlist.aspell.net/&quot;&gt;SCOWL - Spell Checker Oriented Word Lists&lt;/a&gt; &lt;a href=&quot;http://wordlist.aspell.net/scowl-readme/&quot;&gt;(License)&lt;/a&gt; : Ensures genuine English vocabulary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;frequency_dictionary_en_500_000.txt&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are the most frequent 500,000 words from the English One Million list from &lt;a href=&quot;http://storage.googleapis.com/books/ngrams/books/datasetsv2.html&quot;&gt;Google Books Ngram data&lt;/a&gt;, together with their frequency.&lt;/p&gt;

&lt;p&gt;All three test data files are released on GitHub.&lt;/p&gt;

&lt;h2 id=&quot;summary-what-improved-in-the-new-version&quot;&gt;Summary: what improved in the new version&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Faster Damerau-Levenshtein calculation&lt;/strong&gt;, (optimal string alignment (OSA) variant). All 3 Damerau-Levenshtein experiments are faster, by a geometric mean of &lt;strong&gt;10.9×&lt;/strong&gt; (range 10.0× to 12.2×).
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;damerau_levenshtein_osa&lt;/code&gt; using &lt;strong&gt;bit-parallel OSA (&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S157086670400053X/pdf&quot;&gt;Hyyrö 2003&lt;/a&gt;)&lt;/strong&gt; (length &amp;lt;= 64 chars): 10.9x on average (10.0× to 12.2×)&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;damerau_levenshtein_osa_fallback&lt;/code&gt; using the &lt;strong&gt;multi-word block version&lt;/strong&gt; of the &lt;strong&gt;bit-parallel algorithm (&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S157086670400053X/pdf&quot;&gt;Hyyrö 2003&lt;/a&gt;)&lt;/strong&gt; (any length): 6.9x faster on average (6.7x to 8.0x)&lt;/li&gt;
      &lt;li&gt;max edit distance 1: 12.2× (OSA), 8.0 (OSA fallback)&lt;/li&gt;
      &lt;li&gt;max edit distance 2: 10.6× (OSA), 6.2 (OSA fallback)&lt;/li&gt;
      &lt;li&gt;max edit distance 3: 10.0× (OSA), 6.7 (OSA fallback)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Faster lookups in every experiment.&lt;/strong&gt; All 81 lookup experiments are faster, by a geometric mean of &lt;strong&gt;2.8×&lt;/strong&gt; (range 1.5× to 5.9×).
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::Top&lt;/code&gt;: 3.0× on average (1.8× to 5.9×)&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::Closest&lt;/code&gt;: 2.9× on average (1.5× to 4.2×)&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::All&lt;/code&gt;: 2.7× on average (1.6× to 4.8×)&lt;/li&gt;
      &lt;li&gt;max edit distance 1: 2.4× on average (1.5× to 3.7×)&lt;/li&gt;
      &lt;li&gt;max edit distance 2: 2.8× on average (2.1× to 5.2×)&lt;/li&gt;
      &lt;li&gt;max edit distance 3: 3.4× on average (1.8× to 5.9×)&lt;/li&gt;
      &lt;li&gt;30,000-word dictionary: 2.9× on average (1.5× to 4.8×)&lt;/li&gt;
      &lt;li&gt;82,765-word dictionary: 3.0× on average (1.8× to 5.9×)&lt;/li&gt;
      &lt;li&gt;500,000-word dictionary: 2.6× on average (1.6× to 3.5×)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Much lower memory use during lookups.&lt;/strong&gt; Peak heap allocation per lookup is on average only &lt;strong&gt;31%&lt;/strong&gt; of v6.8.4 (best case 17%, worst case 77%).
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::Top&lt;/code&gt;: 18% of v6.8.4 on average (17% to 18%)&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::Closest&lt;/code&gt;: 32% of v6.8.4 on average (18% to 73%)&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::All&lt;/code&gt;: 52% of v6.8.4 on average (33% to 77%)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Roughly 40% less memory for the dictionary.&lt;/strong&gt; Resident memory after the build is on average &lt;strong&gt;62%&lt;/strong&gt; of v6.8.4 (best case 48%, worst case 83%). Peak memory during the build is on average &lt;strong&gt;64%&lt;/strong&gt; of v6.8.4 (48% to 88%).
    &lt;ul&gt;
      &lt;li&gt;Largest example, 500k dictionary, prefix 7, edit distance 3: resident memory 874 MiB → 436 MiB, peak 874 MiB → 436 MiB, build time 14.20 s → 12.60 s.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Build time is on par or slightly better.&lt;/strong&gt; On average the build is 1.09× as fast as v6.8.4 (range 0.86× to 1.58×). 6 of 27 builds are marginally slower (at most 17%), so the memory savings come at no real build-time cost.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;-the-interesting-part&quot;&gt;💡 The interesting part:&lt;/h3&gt;
&lt;p&gt;In the first step, we improved the Damerau-Levenshtein calculation only, while letting the SymSpell implementation unchanged.
An &lt;strong&gt;11x faster edit distance&lt;/strong&gt; gave only a &lt;strong&gt;20% speedup for SymSpell&lt;/strong&gt;. That told us two things:
1️⃣ SymSpell’s makes spelling correction latency largely independent of raw edit distance performance. The symmetric delete algorithm already avoids most of that work. 
2️⃣ Further performance gains had to come from SeekStorm implementation improvements rather than edit distance calculation optimization. We did, and achieved &lt;strong&gt;300% speedup for SymSpell&lt;/strong&gt;.&lt;/p&gt;

&lt;h2 id=&quot;damerau-levenshtein-osa-latency&quot;&gt;Damerau-Levenshtein (OSA) latency&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;strsim v0.11.1 &lt;strong&gt;osa_distance&lt;/strong&gt; uses a vanilla implementation of the Damerau-Levenshtein algorithm.&lt;/li&gt;
  &lt;li&gt;SymSpell v6.8.4 &lt;strong&gt;damerau_levenshtein_osa&lt;/strong&gt; uses a vanilla implementation of the Damerau-Levenshtein algorithm.&lt;/li&gt;
  &lt;li&gt;SymSpell v7.0.1 &lt;strong&gt;damerau_levenshtein_osa&lt;/strong&gt; uses &lt;strong&gt;bit-parallel OSA (&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S157086670400053X/pdf&quot;&gt;Hyyrö 2003&lt;/a&gt;)&lt;/strong&gt; (length &amp;lt;= 64 chars)&lt;/li&gt;
  &lt;li&gt;SymSpell v7.0.1 &lt;strong&gt;damerau_levenshtein_osa_fallback&lt;/strong&gt; uses &lt;strong&gt;multi-word block version&lt;/strong&gt; of the &lt;strong&gt;bit-parallel OSA (&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S157086670400053X/pdf&quot;&gt;Hyyrö 2003&lt;/a&gt;)&lt;/strong&gt; (any length)&lt;/li&gt;
&lt;/ul&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;SymSpell v6.8.4 damerau_levenshtein_osa&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;SymSpell v7.0.1 damerau_levenshtein_osa&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;173 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;14 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;12.18×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;170 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.63×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;178 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;17 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.04×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/osa_symspell_v684_vs_v701.png&quot; alt=&quot;damerau_levenshtein_osa latency&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;&lt;a href=&quot;https://github.com/rapidfuzz/strsim-rs&quot;&gt;strsim v0.11.1&lt;/a&gt; osa_distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;&lt;a href=&quot;https://github.com/wolfgarbe/symspell_rs/&quot;&gt;SymSpell v7.0.1&lt;/a&gt; damerau_levenshtein_osa&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;169 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;14 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;11.89×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;180 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;11.28×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;181 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;17 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.22×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/osa_strsim_vs_symspell_v701.png&quot; alt=&quot;damerau_levenshtein_osa latency&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;SymSpell v6.8.4 damerau_levenshtein_osa&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;SymSpell v7.0.1 damerau_levenshtein_osa_fallback&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;173 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.99×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;170 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;27 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.17×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;178 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;26 ns&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.67×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/osa_fallback_symspell_v684_vs_v701.png&quot; alt=&quot;damerau_levenshtein_osa_fallback latency&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Using noisy_query_en_1000.txt, calculation the edit distance between misspelled_string and corrected_string, for the given maximum edit distance.&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;lookup-latency&quot;&gt;Lookup latency&lt;/h2&gt;

&lt;h3 id=&quot;30000-word-dictionary&quot;&gt;30,000-word dictionary&lt;/h3&gt;

&lt;h4 id=&quot;30000-words-verbositytop&quot;&gt;30,000 words, &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::Top&lt;/code&gt;&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.41 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.27 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.69×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.84 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.28 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.22×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.38 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.12 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.12×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;23.1 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.63 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.48×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;12.6 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.40 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.86×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9.67 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.17 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.05×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;91.7 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.31×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;38.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9.54 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.01×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31.9 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.70 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.76×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/lookup_30k_top.png&quot; alt=&quot;Lookup latency, 30,000 words, Top&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;30000-words-verbosityclosest&quot;&gt;30,000 words, &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::Closest&lt;/code&gt;&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.17 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.22 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.60×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.53 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.27 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.78×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.98 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.31 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.51×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;22.2 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.98 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.18×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;12.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.53 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.66×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.50 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.70 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.30×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;91.1 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.8 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.18×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;38.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.2 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.75×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;23.2 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.05 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.29×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/lookup_30k_closest.png&quot; alt=&quot;Lookup latency, 30,000 words, Closest&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;30000-words-verbosityall&quot;&gt;30,000 words, &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::All&lt;/code&gt;&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.97 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.16 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.76×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.20 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.15 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.42×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.07 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.03 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.50×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;91.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;30.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.04×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;55.2 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;18.6 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.96×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;40.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;19.1 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.11×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;941.9 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;265.5 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.55×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;452.4 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;136.7 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.31×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;431.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;177.1 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.43×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/lookup_30k_all.png&quot; alt=&quot;Lookup latency, 30,000 words, All&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;82765-word-dictionary&quot;&gt;82,765-word dictionary&lt;/h3&gt;

&lt;h4 id=&quot;82765-words-verbositytop&quot;&gt;82,765 words, &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::Top&lt;/code&gt;&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.96 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.36 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.67×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.03 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.10 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.92×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.32 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.42 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.75×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;55.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;24.4 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.27×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;38.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.40 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.17×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;28.1 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.39 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.80×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;319.4 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;54.6 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.85×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;139.1 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;32.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.35×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;39.4 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.6 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.83×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/lookup_82k_top.png&quot; alt=&quot;Lookup latency, 82,765 words, Top&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;82765-words-verbosityclosest&quot;&gt;82,765 words, &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::Closest&lt;/code&gt;&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.28 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.40 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.62×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.60 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.74 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.22×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.39 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.74 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.67×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;55.4 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;23.9 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.32×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;29.9 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.2 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.93×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;18.4 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.88 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.34×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;315.8 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;89.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.55×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;86.2 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.04×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;65.4 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.07×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/lookup_82k_closest.png&quot; alt=&quot;Lookup latency, 82,765 words, Closest&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;82765-words-verbosityall&quot;&gt;82,765 words, &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::All&lt;/code&gt;&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9.64 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.47 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.16×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.20 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.53 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.04×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.7 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.59 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.98×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;335.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;86.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.89×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;121.9 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;52.7 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.31×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;106.1 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;45.9 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.31×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.89 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;808.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.81×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.66 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;424.8 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.91×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.02 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;421.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.42×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/lookup_82k_all.png&quot; alt=&quot;Lookup latency, 82,765 words, All&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;500000-word-dictionary&quot;&gt;500,000-word dictionary&lt;/h3&gt;

&lt;h4 id=&quot;500000-words-verbositytop&quot;&gt;500,000 words, &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::Top&lt;/code&gt;&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;15.5 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.47 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.40×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.32 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.24 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.26×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.74 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.85 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.01×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;241.7 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;81.1 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.98×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;107.6 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;35.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.05×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;30.8 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;12.6 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.44×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.06 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;316.5 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.35×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;307.9 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;87.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.54×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;80.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;29.1 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.77×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/lookup_500k_top.png&quot; alt=&quot;Lookup latency, 500,000 words, Top&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;500000-words-verbosityclosest&quot;&gt;500,000 words, &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::Closest&lt;/code&gt;&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.4 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.79 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.42×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.1 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.77 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.49×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.72 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.15 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.82×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;243.6 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;90.5 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.69×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;66.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;25.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.66×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;36.8 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.2 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.79×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.07 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;302.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.54×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;348.2 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;103.7 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.36×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;79.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;30.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.61×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/lookup_500k_closest.png&quot; alt=&quot;Lookup latency, 500,000 words, Closest&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;500000-words-verbosityall&quot;&gt;500,000 words, &lt;code class=&quot;highlighter-rouge&quot;&gt;Verbosity::All&lt;/code&gt;&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;speedup&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;72.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;22.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.28×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;29.0 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;18.4 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.57×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;27.9 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.2 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.72×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.84 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;677.9 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.71×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.02 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;415.8 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.45×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;990.3 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;406.6 µs&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.44×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;25.48 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9.25 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.75×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.93 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.85 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.84×&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9.66 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.12 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.34×&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/lookup_500k_all.png&quot; alt=&quot;Lookup latency, 500,000 words, All&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;dictionary-build&quot;&gt;Dictionary build&lt;/h2&gt;

&lt;h3 id=&quot;build-time&quot;&gt;Build time&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;dictionary&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max dictionary edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;change&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;48 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;44 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.09× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;148 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;125 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.18× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;217 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;197 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.10× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;58 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;51 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.14× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;198 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;190 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.04× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;339 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;346 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.02× slower&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;77 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;69 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.11× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;267 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;246 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.08× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;781 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;635 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.23× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;254 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;160 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.58× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;462 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;499 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.08× slower&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;736 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;859 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.17× slower&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;234 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;238 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.02× slower&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;813 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;843 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.04× slower&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.40 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.20 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.17× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;246 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;212 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.16× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.00 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;966 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.04× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.30 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.20 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.05× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.40 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;963 ms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.45× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.20 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.00 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.07× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.80 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.70 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.02× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.70 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.70 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;same&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.20 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.30 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.02× slower&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.70 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.60 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.02× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.00 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.60 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.25× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.40 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.10 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.05× faster&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;14.20 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;12.60 s&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.13× faster&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/build_time.png&quot; alt=&quot;Build time&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;resident-memory&quot;&gt;Resident memory&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;dictionary&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max dictionary edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;change&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.6 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.5 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-24%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.3 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-42%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;23.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;12.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-49%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;11.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-21%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;26.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.9 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-35%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;40.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;22.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-45%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;15.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-17%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;38.0 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;26.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-31%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;59.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;34.3 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-43%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.6 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-24%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;44.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;24.9 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-44%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;66.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;33.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-50%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;27.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-23%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;68.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;41.3 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-39%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;109.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;56.3 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-48%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;37.5 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;30.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-20%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;96.0 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;61.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-36%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;161.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;85.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-47%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;128.3 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;91.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-29%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;261.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;141.3 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-46%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;390.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;189.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-52%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;154.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;111.6 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-28%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;376.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;214.0 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-43%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;611.9 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;300.5 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-51%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;195.5 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;147.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-25%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;502.5 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;300.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-40%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;874.0 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;435.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-50%&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/resident.png&quot; alt=&quot;Resident memory&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;peak-memory-during-build&quot;&gt;Peak memory during build&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;dictionary&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max dictionary edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;change&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9.3 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.3 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-22%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.9 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-40%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;24.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;12.9 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-47%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;11.9 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9.6 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-19%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;26.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;18.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-32%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;40.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;22.6 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-44%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;18.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.0 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-12%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;39.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31.5 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-19%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;30,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;59.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;34.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-42%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.6 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-24%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;44.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;24.9 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-44%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;66.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;33.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-50%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;27.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-23%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;68.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;41.3 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-39%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;109.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;56.3 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-48%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;38.0 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;32.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-14%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;96.0 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;65.6 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-32%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;82,765&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;161.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;85.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-47%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;133.6 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;101.0 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-24%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;261.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;146.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-44%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;390.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;189.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-52%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;159.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;120.6 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-24%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;376.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;225.0 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-40%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;611.9 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;302.4 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-51%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;199.2 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;155.9 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-22%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;502.5 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;305.8 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-39%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;500,000&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;874.1 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;435.7 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-50%&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/peak.png&quot; alt=&quot;Peak memory during build&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;peak-heap-allocation-during-lookups&quot;&gt;Peak heap allocation during lookups&lt;/h2&gt;

&lt;p&gt;Peak heap allocation of a single lookup (tracking global allocator); lower is better. Ratio = current ÷ v6.8.4.&lt;/p&gt;

&lt;h3 id=&quot;30000-word-dictionary-1&quot;&gt;30,000-word dictionary&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Top v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Top current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Closest v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Closest current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;All v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;All current&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.5 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.0 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.8 KiB (48%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.9 KiB (49%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.5 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.0 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.8 KiB (48%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.9 KiB (49%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.5 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.0 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.8 KiB (48%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.9 KiB (49%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;42.1 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.5 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;47.2 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;14.6 KiB (31%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;62.9 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;38.2 KiB (61%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.6 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.8 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31.4 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;14.6 KiB (47%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;63.1 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;38.2 KiB (61%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;21.6 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.8 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31.4 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;14.6 KiB (47%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;63.1 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;38.2 KiB (61%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;166.7 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;30.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;169.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31.5 KiB (19%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;497.1 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;245.5 KiB (49%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;86.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;15.0 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;88.6 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.5 KiB (19%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;416.3 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;225.5 KiB (54%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;46.8 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.5 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;49.4 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;14.6 KiB (30%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;293.8 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;225.5 KiB (77%)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;82765-word-dictionary-1&quot;&gt;82,765-word dictionary&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Top v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Top current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Closest v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Closest current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;All v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;All current&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.6 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.0 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.7 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.3 KiB (49%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.8 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.0 KiB (37%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.6 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.0 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.7 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.3 KiB (49%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.3 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.0 KiB (48%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.6 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.0 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.7 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.3 KiB (49%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.3 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.0 KiB (48%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;83.5 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;15.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;86.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.5 KiB (19%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;125.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;67.8 KiB (54%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;22.5 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.8 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;26.9 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.2 KiB (38%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;125.3 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;67.8 KiB (54%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;22.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.8 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;27.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.2 KiB (38%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;125.3 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;67.8 KiB (54%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;332.3 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;60.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;334.3 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;61.5 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.45 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;493.5 KiB (33%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;168.1 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;30.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;170.7 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31.5 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;834.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;453.5 KiB (54%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;88.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;90.2 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;17.5 KiB (19%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;833.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;453.5 KiB (54%)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;500000-word-dictionary-1&quot;&gt;500,000-word dictionary&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;max edit distance&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;prefix length&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Top v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Top current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Closest v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Closest current&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;All v6.8.4&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;All current&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;11.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.9 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;18.5 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.5 KiB (73%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;42.3 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;15.9 KiB (37%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.9 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.9 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;18.5 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.5 KiB (73%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31.3 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;15.9 KiB (51%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.9 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.9 KiB (17%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;18.5 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.5 KiB (73%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31.3 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;15.9 KiB (51%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;329.8 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;60.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;332.4 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;61.5 KiB (19%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;992.1 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;484.6 KiB (49%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;85.4 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;15.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;89.1 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;22.5 KiB (25%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;992.1 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;484.6 KiB (49%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;83.5 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;15.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;94.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;22.5 KiB (24%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;992.1 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;484.6 KiB (49%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.58 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;480.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.58 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;486.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.76 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.89 MiB (50%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;666.0 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;120.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;668.7 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;123.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.49 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.57 MiB (55%)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;335.2 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;61.0 KiB (18%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;340.6 KiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;64.0 KiB (19%)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.61 MiB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.57 MiB (77%)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;notes&quot;&gt;Notes&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Each lookup experiment is a short run, so single cells can be noisy; the trend is consistent across all 81 experiments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;related-blog-posts-algorithm-benchmarks-applications&quot;&gt;Related Blog Posts: Algorithm, Benchmarks, Applications&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://seekstorm.com/blog/1000x-spelling-correction/&quot;&gt;1000x Faster Spelling Correction algorithm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://seekstorm.com/blog/fast-approximate-string-matching/&quot;&gt;Fast approximate string matching with large edit distances in Big Data&lt;/a&gt;&lt;br /&gt; 
&lt;a href=&quot;https://seekstorm.com/blog/very-data-cleaning-of-product-names-company-names-street-names/&quot;&gt;Very fast Data cleaning of product names, company names &amp;amp; street names&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://seekstorm.com/blog/sub-millisecond-compound-aware-automatic.spelling-correction/&quot;&gt;Sub-millisecond compound aware automatic spelling correction&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://seekstorm.com/blog/symspell-vs-bk-tree/&quot;&gt;SymSpell vs. BK-tree: 100x faster fuzzy string search &amp;amp; spell checking&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://seekstorm.com/blog/fast-word-segmentation-noisy-text/&quot;&gt;Fast Word Segmentation for noisy text&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://seekstorm.com/blog/pruning-radix-trie/&quot;&gt;The Pruning Radix Trie — a Radix trie on steroids&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;application&quot;&gt;Application&lt;/h2&gt;
&lt;p&gt;Possible application fields of the SymSpell algorithm are those of fast approximate dictionary string matching: spell checkers for word processors and search engines, correction systems for optical character recognition, natural language translation based on translation memory, record linkage, de-duplication, matching DNA sequences, fuzzy string searching and fraud detection.&lt;/p&gt;

&lt;p&gt;For a single user or for small edit distances other algorithms might just be fine. But for &lt;a href=&quot;https://github.com/SeekStorm/SeekStorm&quot;&gt;search engines&lt;/a&gt; and &lt;a href=&quot;https://seekstorm.com/&quot;&gt;search-as-a-service&lt;/a&gt; search API where you have to serve thousands of concurrent users, while still maintaining a latency of a few milliseconds, and where spelling correction is not even the main procession task, but only one of many components in query preprocessing, you need the fastest spelling correction you can get.&lt;/p&gt;

&lt;h2 id=&quot;source-code&quot;&gt;Source code&lt;/h2&gt;
&lt;p&gt;The Rust implementation of the Symmetric Delete Spelling Correction algorithm is released on &lt;a href=&quot;https://github.com/wolfgarbe/symspell_rs&quot;&gt;GitHub&lt;/a&gt; as &lt;strong&gt;Open Source&lt;/strong&gt; under the &lt;strong&gt;MIT license&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The C# implementation of the Symmetric Delete Spelling Correction algorithm is released on &lt;a href=&quot;https://github.com/wolfgarbe/symspell&quot;&gt;GitHub&lt;/a&gt; as &lt;strong&gt;Open Source&lt;/strong&gt; under the &lt;strong&gt;MIT license&lt;/strong&gt;.&lt;/p&gt;

&lt;h2 id=&quot;ports&quot;&gt;Ports&lt;/h2&gt;
&lt;p&gt;There are &lt;a href=&quot;https://github.com/wolfgarbe/symspell_rs#ports&quot;&gt;ports&lt;/a&gt; in C, C++, Crystal, Go, Haskell, Java, Javascript, Julia, Kotlin, Objective-C, PHP, Python, Ruby, Rust, Scala, Swift and Zig available.&lt;/p&gt;
</description>
        <pubDate>Tue, 06 Oct 2026 00:00:00 +0000</pubDate>
        <link>https://seekstorm.com/blog/symspell_rs-3x-faster-lookup-40-less-memory-11x-faster-levenshtein/</link>
        <guid isPermaLink="true">https://seekstorm.com/blog/symspell_rs-3x-faster-lookup-40-less-memory-11x-faster-levenshtein/</guid>
        
        
        <category>algorithm</category>
        
        <category>performance</category>
        
        <category>rust</category>
        
        <category>oss</category>
        
        <category>symspell</category>
        
      </item>
    
      <item>
        <title>🔥SeekStorm 3.0 adds vector search &amp; hybrid search</title>
        <description>&lt;h3 id=&quot;seekstorm-uses-two-separate-first-class-native-index-architectures-under-one-roof&quot;&gt;SeekStorm uses &lt;strong&gt;two&lt;/strong&gt; separate, &lt;strong&gt;first-class&lt;/strong&gt;, &lt;strong&gt;native&lt;/strong&gt; index architectures, under one roof.&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Lexical search&lt;/strong&gt; (sparse retrieval): sharded and leveled inverted index.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Vector search&lt;/strong&gt; (dense retrieval): sharded and leveled IVF index for ANN or exhaustive search.&lt;/li&gt;
  &lt;li&gt;Shared document store, shared document ID space.&lt;/li&gt;
  &lt;li&gt;Both first-class engines are integrated at the query planner level.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Query planner&lt;/strong&gt; with QueryModes (Lexical, Vector, Hybrid…) and FusionTypes (RRF, …).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;why-hybrid-search&quot;&gt;Why hybrid search?&lt;/h3&gt;

&lt;p&gt;Because lexical search and vector search &lt;strong&gt;complement each other&lt;/strong&gt;. We can significantly &lt;strong&gt;improve result quality&lt;/strong&gt; with hybrid search by combining their strengths, while compensating their shortcomings.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Lexical search&lt;/strong&gt; is fast, precise, exact, and language independent - but unable to deal with meaning and semantic similarity.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Vector search&lt;/strong&gt; understands similarities - but is language dependent, can’t deal with new or rare terms it wasn’t trained for, it is slower and more expensive.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;keyword-search-lexical-search&quot;&gt;Keyword search (lexical search)&lt;/h4&gt;
&lt;p&gt;If you search for exact results like proper names, numbers, license plates, domain names, and phrases (e.g. plagiarism detection) then keyword search is your friend. Vector search, on the other hand, will bury the exact result that you are looking for among a myriad of results that are only somehow semantically related. At the same time, if you don’t know the exact terms, or you are interested in a broader topic, meaning or synonym, no matter what exact terms are used, then keyword search will fail you.&lt;/p&gt;

&lt;div class=&quot;language-diff highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;gd&quot;&gt;- works with text data only
- unable to capture context, meaning and semantic similarity
- low recall for semantic meaning
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+ perfect recall for exact keyword match 
+ perfect precision (for exact keyword match)
+ high query speed and throughput (for large document numbers)
+ high indexing speed (for large document numbers)
+ incremental indexing fully supported
+ smaller index size
+ lower infrastructure cost per document and per query, lower energy consumption
+ good scalability (for large document numbers)
+ perfect for exact keyword and phrase search, no false positives
+ perfect explainability
+ efficient and lossless for exact keyword and phrase search
+ works with new vocabulary out of the box
+ works with any language out of the box
+ works perfect with long-tail vocabulary out of the box
+ works perfect with any rare language or domain-specific vocabulary out of the box
+ RAG (Retrieval-augmented generation) based on keyword search offers unrestricted real-time capabilities.
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;vector-search&quot;&gt;Vector search&lt;/h4&gt;
&lt;p&gt;Vector search is perfect if you don’t know the exact query terms, or you are interested in a broader topic, meaning or synonym, no matter what exact query terms are used. But if you are looking for exact terms, e.g. proper names, numbers, license plates, domain names, and phrases (e.g. plagiarism detection) then you should always use keyword search. Vector search will instead bury the exact result that you are looking for among a myriad of results that are only somehow related. It has a good recall, but low precision, and higher latency. It is prone to false positives, e.g., in plagiarism detection as exact words and word order get lost.&lt;/p&gt;

&lt;p&gt;Vector search enables you to search not only for similar text, but for everything that can be transformed into a vector: text, images (face recognition, fingerprints), audio, enabling you to do magic things like “queen - woman + man = king.”&lt;/p&gt;

&lt;div class=&quot;language-diff highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;gi&quot;&gt;+ works with any data that can be transformed to a vector: text, image, audio ...
+ able to capture context, meaning, and semantic similarity
+ high recall for semantic meaning
&lt;/span&gt;&lt;span class=&quot;gd&quot;&gt;- lower recall for exact keyword match (for Approximate Similarity Search)
- lower precision (for exact keyword match)
- lower query speed and throughput (for large document numbers)
- lower indexing speed (for large document numbers)
- incremental indexing is expensive and requires rebuilding the entire index periodically, which is extremely time-consuming and resource intensive.
- larger index size
- higher infrastructure cost per document and per query, higher energy consumption
- limited scalability (for large document numbers)
- unsuitable for exact keyword and phrase search, many false positives
- low explainability makes it difficult to spot manipulations, bias and root cause of retrieval/ranking problems
- inefficient and lossy for exact keyword and phrase search
- Additional effort and cost to create embeddings and keep them updated for every language and domain. Even if the number of indexed documents is small, the embeddings have to created from a large corpus before nevertheless.
- Limited real-time capability due to limited recency of embeddings
- works only with vocabulary known at the time of embedding creation
- works only with the languages of the corpus from which the embeddings have been derived
- works only with long-tail vocabulary that was sufficiently represented in the corpus from which the embeddings have been derived
- works only with rare language or domain-specific vocabulary that was sufficiently represented in the corpus from which the embeddings have been derived
- RAG (Retrieval-augmented generation) based on vector search offers only limited real-time capabilities, as it can't process new vocabulary that arrived after the embedding generation
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;vector-features&quot;&gt;Vector Features&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Multi-Vector indexing&lt;/strong&gt;: both from multiple fields and from multiple chunks per field.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Integrated inference&lt;/strong&gt; from any text document field or Import external embeddings.&lt;/li&gt;
  &lt;li&gt;Variable &lt;strong&gt;dimensions&lt;/strong&gt; and &lt;strong&gt;precisions&lt;/strong&gt;: &lt;strong&gt;f32, i8&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Scalar Quantization&lt;/strong&gt; (SQ).&lt;/li&gt;
  &lt;li&gt;Multiple &lt;strong&gt;similarity measures&lt;/strong&gt;: Cosine similarity, Dot product, Euclidean distance.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Chunking&lt;/strong&gt; that respects sentence boundaries and Unicode segmentation for multilingual text.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;K-medoid clustering&lt;/strong&gt; with actual data points as centers.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Field filters&lt;/strong&gt; are active during vector search, not just as post-search filtering step.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;True real-time search&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;disk-based &lt;strong&gt;billion-scale vector search&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Sub-millisecond search&lt;/strong&gt; for 1 million vectors on a laptop, CPU only:
    &lt;ul&gt;
      &lt;li&gt;
        &lt;table&gt;
          &lt;tbody&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Sift1M&lt;/strong&gt; recall@10=95%, 0.2 ms&lt;/td&gt;
              &lt;td&gt;recall@10=99%, 0.3 ms&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;See &lt;a href=&quot;https://github.com/SeekStorm/SeekStorm/blob/main/CHANGELOG.md&quot;&gt;CHANGELOG.md&lt;/a&gt; for details.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\server_info_combined.png&quot; alt=&quot;Server info &amp;amp; vector search results&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;

&lt;h3 id=&quot;dual-engine-architecture-for-hybrid-search&quot;&gt;Dual Engine Architecture for Hybrid Search&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Internally, SeekStorm uses &lt;strong&gt;two separate, first-class, native index architectures&lt;/strong&gt; for &lt;strong&gt;vector search&lt;/strong&gt; and &lt;strong&gt;keyword search&lt;/strong&gt;. Two native cores, not just a retrofit, add-on layer.&lt;/li&gt;
  &lt;li&gt;SeekStorm doesn’t try to make one index do everything. It runs two native search engines and lets the query planner decide how to combine them.&lt;/li&gt;
  &lt;li&gt;Two native index architectures under one roof:
    &lt;ul&gt;
      &lt;li&gt;Lexical search (sparse retrieval): an inverted index optimized for lexical relevance,&lt;/li&gt;
      &lt;li&gt;Vector search (dense retrieval): an ANN index optimized for vector similarity.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Both are first-class engines, integrated at the query planner level.
    &lt;ul&gt;
      &lt;li&gt;Query planner with dedicated QueryModes and FusionTypes&lt;/li&gt;
      &lt;li&gt;Query planner mode can be automatically or manually selected.&lt;/li&gt;
      &lt;li&gt;Active QueryModes mode is returned for explainability, relatability and credibility.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Separate internal index, storage layouts, indexing, search, scoring, top-k candidates - unified query planner and result fusion (Reciprocal Rank Fusion - RRF).&lt;/li&gt;
  &lt;li&gt;But the user is fully shielded from the complexity, as if it was only a single index.&lt;/li&gt;
  &lt;li&gt;Enables pure lexical, pure vector or hybrid search (exhaustive, not only re-ranking of preliminary candidates).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;                        ┌────────────────────┐
                        │     User / API     │
                        │   (hybrid query)   │
                        └─────────┬──────────┘
                                  │
                                  ▼
                        ┌────────────────────┐
                        │    Query Planner   │
                        │ (intent + strategy)│
                        └───────┬───────┬────┘
                                │       │
                 ┌──────────────┘       └──────────────┐
                 ▼                                     ▼
        ┌────────────────────┐            ┌────────────────────┐
        │ Lexical Engine     │            │ Vector Engine      │
        │ Inverted Index     │            │ Native ANN Index   │
        │ (BM25 / Boolean)   │            │ (Leveled‑IVF)      │
        └─────────┬──────────┘            └─────────┬──────────┘
                  │                                 │
                  ▼                                 ▼
          Ranked Results L                    Ranked Results V
                  │                                 │
                  └───────┬───────────────┬─────────┘
                          ▼               ▼
                    ┌────────────────────────────┐
                    │       Result Fusion        │
                    │ (RRF / rerank strategies)  │
                    │                            │
                    └────────────┬───────────────┘
                                 ▼
                        Final Ranked Results
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;leveled-ivf-index-vector&quot;&gt;Leveled IVF index (vector)&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Disk-based&lt;/strong&gt;, &lt;strong&gt;Leveled IVF index&lt;/strong&gt; for unlimited index size.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Sharded index&lt;/strong&gt; for lock-free utilization of all processor cores.&lt;/li&gt;
  &lt;li&gt;true &lt;strong&gt;real-time&lt;/strong&gt; indexing and search capable.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Approximate Nearest Neighbor Search&lt;/strong&gt; (ANNS) and exhaustive &lt;strong&gt;k-nearest neighbor&lt;/strong&gt; search (kNN)&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;K-Medoid clustering&lt;/strong&gt;: PAM (Partition Around Medoids) with actual data points as centers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;benchmark-vector-search-sift1m-gist1m&quot;&gt;Benchmark vector search (SIFT1M, GIST1M)&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\vector_search_benchmark.png&quot; width=&quot;1000&quot; alt=&quot;Benchmark&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;

&lt;h4 id=&quot;sift1m-dataset-1-million-vectors-128-dimensions-f32-precision-euclidean&quot;&gt;&lt;a href=&quot;http://corpus-texmex.irisa.fr/&quot;&gt;SIFT1M dataset&lt;/a&gt; 1 million vectors, 128 dimensions, f32 precision, Euclidean&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;8-bit Scalar Quantization, nprobe=16 -&amp;gt; recall@10=95%, average latency=188 microseconds&lt;/li&gt;
  &lt;li&gt;8-bit Scalar Quantization, nprobe=33 -&amp;gt; recall@10=99%, average latency=302 microseconds&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h4 id=&quot;gist1m-dataset-1-million-vectors-960-dimensions-f32-precision-euclidean&quot;&gt;&lt;a href=&quot;http://corpus-texmex.irisa.fr/&quot;&gt;GIST1M dataset&lt;/a&gt; 1 million vectors, 960 dimensions, f32 precision, Euclidean&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;8-bit Scalar Quantization, nprobe=38 -&amp;gt; recall@10=95%, average latency=3,198 microseconds&lt;/li&gt;
  &lt;li&gt;8-bit Scalar Quantization, nprobe=80 -&amp;gt; recall@10=98%, average latency=5,737 microseconds&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/SeekStorm/SeekStorm#vector-search-sift1m-dataset&quot;&gt;Benchmark code&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;benchmark-vector-search-vs-lexical-search-wikipedia&quot;&gt;Benchmark vector search vs. lexical search (Wikipedia)&lt;/h3&gt;

&lt;p&gt;There are benchmarks of vector search engines, and benchmarks of lexical search engines.&lt;br /&gt;
But seeing the latency of lexical search and vector search stacked up against each other might offer some unique insight.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\vector_lexical_benchmark.png&quot; width=&quot;1000&quot; alt=&quot;Benchmark&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;English Wikipedia&lt;/strong&gt;: 5 million documents, 16 million vectors&lt;br /&gt;
Lexical: 2 fields, top10, BM25, average latency	305 microseconds&lt;br /&gt;
Vector: 2 fields, nprobe=68 -&amp;gt; recall@10=95%, average latency 2,700 microseconds&lt;br /&gt;
Vector: 2 fields, nprobe=200 -&amp;gt; recall@10=99%, average latency 6,370 microseconds&lt;br /&gt;
Using &lt;a href=&quot;https://github.com/MinishLab/model2vec-rs&quot;&gt;Model2Vec from MinishLab&lt;/a&gt;: PotionBase2M, chunks: 1000 byte&lt;/p&gt;

&lt;p&gt;We are using the &lt;strong&gt;English Wikipedia&lt;/strong&gt; data (&lt;em&gt;5 million entries&lt;/em&gt;) and queries (&lt;em&gt;300 intersection queries&lt;/em&gt;) derived from the &lt;strong&gt;AOL query dataset&lt;/strong&gt;, both from &lt;a href=&quot;https://github.com/quickwit-oss/search-benchmark-game/&quot;&gt;Tantivy’s search-benchmark-game&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;repository&quot;&gt;Repository&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;SeekStorm: vector &amp;amp; lexical search - in-process library &amp;amp; multi-tenancy server, in Rust.&lt;/strong&gt;&lt;br /&gt;
SeekStorm is open-source, under the Apache-2.0 license, available at our &lt;a href=&quot;https://github.com/SeekStorm/SeekStorm&quot;&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;

</description>
        <pubDate>Mon, 20 Apr 2026 00:00:00 +0000</pubDate>
        <link>https://seekstorm.com/blog/seekstorm-adds-vector_search-hybrid-search/</link>
        <guid isPermaLink="true">https://seekstorm.com/blog/seekstorm-adds-vector_search-hybrid-search/</guid>
        
        
        <category>search</category>
        
        <category>performance</category>
        
        <category>rust</category>
        
        <category>oss</category>
        
      </item>
    
      <item>
        <title>Document iterator and search with empty query string</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;SeekStorm introduces a new &lt;strong&gt;Document Iterator API&lt;/strong&gt; and support &lt;strong&gt;search with empty query strings&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;document-iterator&quot;&gt;Document iterator&lt;/h3&gt;

&lt;p&gt;The Document iterator API lets you &lt;strong&gt;iterate over all document IDs&lt;/strong&gt;—and documents—in the entire index, &lt;strong&gt;forward&lt;/strong&gt; or &lt;strong&gt;backward&lt;/strong&gt;. It enables efficient sequential access to every document, even in very large indexes, without running a search.&lt;/p&gt;

&lt;p&gt;The iterator guarantees that &lt;strong&gt;only valid document IDs&lt;/strong&gt; are returned, even though &lt;strong&gt;document IDs are not strictly continuous&lt;/strong&gt;. You can also &lt;strong&gt;fetch IDs in batches&lt;/strong&gt;, reducing round trips and significantly improving performance, especially when using the REST API.&lt;/p&gt;

&lt;p&gt;In SeekStorm, document IDs become continuous over time (&lt;strong&gt;“eventually continuous”&lt;/strong&gt;). In a multi-sharded index, each shard maintains its own document ID space. Because documents are distributed across shards in a non-deterministic, load-dependent way, shard-local document IDs advance at different rates. When these are mapped to global document IDs, &lt;strong&gt;temporary gaps can appear&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;As a result, simply iterating from 0 to the total document count may encounter &lt;strong&gt;invalid IDs near the end&lt;/strong&gt;. The new Document ID Iterator API abstracts this complexity and reliably &lt;strong&gt;returns only valid document IDs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Iterator parameter:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;include_deleted&lt;/code&gt; returns also deleted document ID.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;include_document&lt;/code&gt; returns documents along document IDs.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;fields&lt;/code&gt; specifies which document fields to return.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Typical use cases include index export, conversion, analytics, audits, and inspection.&lt;/p&gt;

&lt;h3 id=&quot;search-with-empty-query&quot;&gt;Search with empty query:&lt;/h3&gt;

&lt;p&gt;Added search features:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;enable_empty_query&lt;/code&gt;: iterator across all indexed documents
    &lt;ul&gt;
      &lt;li&gt;query parameters supported for empty queries: offset, length, query_facets, facet_filter, result_sort&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Two special fields: ` _score ` and ` _id `
    &lt;ul&gt;
      &lt;li&gt;sort ascending, or descending (i.e. by relevance or modification date)&lt;/li&gt;
      &lt;li&gt;for search with and without query&lt;/li&gt;
      &lt;li&gt;special fields are automatically injected into result documents.&lt;/li&gt;
      &lt;li&gt;If &lt;code class=&quot;highlighter-rouge&quot;&gt;result_sort&lt;/code&gt; is used with any other than the special field &lt;code class=&quot;highlighter-rouge&quot;&gt;_id&lt;/code&gt;, or query_facets or facet_filter are used, 
then a min-heap consumes RAM proportional to &lt;strong&gt;offset + length&lt;/strong&gt;.&lt;br /&gt;
Per default or if sort field &lt;code class=&quot;highlighter-rouge&quot;&gt;_id&lt;/code&gt; is specified, the consumed RAM is proportional to &lt;strong&gt;length&lt;/strong&gt;.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Typical use cases include facet filtering and sorting of all documents in the index.&lt;/p&gt;

</description>
        <pubDate>Wed, 28 Jan 2026 00:00:00 +0000</pubDate>
        <link>https://seekstorm.com/blog/document-iterator-search-with-empty-query-string/</link>
        <guid isPermaLink="true">https://seekstorm.com/blog/document-iterator-search-with-empty-query-string/</guid>
        
        
        <category>search</category>
        
        <category>performance</category>
        
        <category>rust</category>
        
        <category>oss</category>
        
      </item>
    
      <item>
        <title>Typo-tolerant Query auto-completion (QAC) - derived from indexed documents</title>
        <description>&lt;p&gt;— work in progress, live reporting from the lab 😀 —&lt;/p&gt;

&lt;h2 id=&quot;tldr--typo--and-word-order-tolerant-query-auto-completion-qac---derived-from-indexed-documents-instead-of-from-query-logs&quot;&gt;TLDR : Typo- and word-order tolerant Query auto-completion (QAC) - derived from indexed documents instead of from query logs&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;Providing the user with query completions while typing has many benefits: it &lt;strong&gt;saves time&lt;/strong&gt;, &lt;strong&gt;prevents and corrects spelling mistakes&lt;/strong&gt;, makes sure &lt;strong&gt;queries are aligned with index content&lt;/strong&gt;, 
&lt;strong&gt;helps the user to formulate queries&lt;/strong&gt; if he is unsure about the terms, their spelling or the content of the index.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;But implementing QAC at scale also comes with many challenges: how to &lt;strong&gt;collect, count and select the completions&lt;/strong&gt;, with &lt;strong&gt;low memory requirement&lt;/strong&gt;, &lt;strong&gt;low performance impact&lt;/strong&gt;, and &lt;strong&gt;high relevance&lt;/strong&gt;. 
And how to &lt;strong&gt;rank and serve them to the user&lt;/strong&gt; with &lt;strong&gt;low latency&lt;/strong&gt;, even for &lt;strong&gt;large indices&lt;/strong&gt; and &lt;strong&gt;many concurrent users&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;In the blog post we &lt;strong&gt;analyze those challenges&lt;/strong&gt;, &lt;strong&gt;explore the solution space&lt;/strong&gt; and present our &lt;strong&gt;open source implementation&lt;/strong&gt; - 
both our &lt;strong&gt;standalone library SymSpellComplete&lt;/strong&gt; as well as its &lt;strong&gt;integration into our SeekStorm search library and server&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;p&gt;This blog post describes two components of our recent work to build a typo-tolerant Query auto-completion (QAC) system, where the completions are derived from indexed documents as opposed from query-logs.
We discuss our research into prior art and related work, algorithms, data structure, challenges in scaling and resource consumption, experiments and our final solution.&lt;/p&gt;

&lt;h3 id=&quot;symspellcomplete-a-typo--and-word-order-tolerant-autocomplete-library-in-rust&quot;&gt;SymSpellComplete, a typo- and word-order tolerant autocomplete library in Rust.&lt;/h3&gt;

&lt;p&gt;Like a combination of &lt;a href=&quot;https://seekstorm.com/blog/symspell-vs-bk-tree/&quot;&gt;SymSpell&lt;/a&gt; (&lt;a href=&quot;https://github.com/wolfgarbe/SymSpell&quot;&gt;repo&lt;/a&gt;) and &lt;a href=&quot;https://seekstorm.com/blog/pruning-radix-trie/&quot;&gt;PruningRadixTrie&lt;/a&gt; (&lt;a href=&quot;https://github.com/wolfgarbe/PruningRadixTrie&quot;&gt;repo&lt;/a&gt;), but better:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Typo-tolerant &amp;amp; word-order tolerant.&lt;/li&gt;
  &lt;li&gt;Query terms might contain spelling errors, even in the first letter of an incomplete term: &lt;code class=&quot;highlighter-rouge&quot;&gt;blu kura&lt;/code&gt; -&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;blue curacao&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Handles missing and mistakenly inserted spaces: &lt;code class=&quot;highlighter-rouge&quot;&gt;modernart&lt;/code&gt; -&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;modern art&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Supports differing order between query and completion terms:  &lt;code class=&quot;highlighter-rouge&quot;&gt;university dre&lt;/code&gt; -&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;dresden university of technology&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Allows out-of-vocabulary terms (not all query terms are present in completions): &lt;code class=&quot;highlighter-rouge&quot;&gt;teal merino cardi&lt;/code&gt; -&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;merino cardigan&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Multi-term completions using term co-occurrence probabilities for ranking.&lt;/li&gt;
  &lt;li&gt;The SymSpellComplete library is implemented in Rust, and available as open-source under the MIT license.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;typo--and-word-order-tolerant-query-auto-completion-qac-in-the-seekstorm-full-text-search-library--multi-tenancy-server-using-symspellcomplete&quot;&gt;Typo- and word-order tolerant Query Auto-Completion (QAC) in the SeekStorm full-text search library &amp;amp; multi-tenancy server, using SymSpellComplete.&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;The completions are automatically derived in real-time from indexed documents, not from a query log.&lt;/li&gt;
  &lt;li&gt;works, even if no query log is available, especially for domain-specific, newly created indices or few users.&lt;/li&gt;
  &lt;li&gt;works for new or domain-specific terms.&lt;/li&gt;
  &lt;li&gt;allows out-of-the-box domain specific suggestions&lt;/li&gt;
  &lt;li&gt;prevents inconsistencies between completions and index content.&lt;/li&gt;
  &lt;li&gt;Query logs contains invalid queries: because its sourced from a different index or because users don’t know the content of your index..&lt;/li&gt;
  &lt;li&gt;Works for the long tail of queries, that never made it to a log.&lt;/li&gt;
  &lt;li&gt;suggestions tailored per index.&lt;/li&gt;
  &lt;li&gt;completion prevents spelling errors and saves time&lt;/li&gt;
  &lt;li&gt;language-, content- and domain-independent&lt;/li&gt;
  &lt;li&gt;additionally allows to use hand crafted completion files&lt;/li&gt;
  &lt;li&gt;Ghosting: highlighting the suggested text within the search box in the UI&lt;/li&gt;
  &lt;li&gt;The SeekStorm lexical search library and server are implemented in Rust, and available as open-source under the MIT license.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;table-of-contents&quot;&gt;Table of contents&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#problem-statement-and-requirements&quot;&gt;Problem statement and desired functionality&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#why-query-completion&quot;&gt;Why query completion?&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#desired-functionality&quot;&gt;Desired functionality&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#integral-functionality-vs-external-component&quot;&gt;Integral functionality vs. external component&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#query-and-completion-lengths&quot;&gt;Query and completion lengths&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#completion-data-sources&quot;&gt;Completion data sources&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#from-query-logs&quot;&gt;From query logs&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#from-document-corpus&quot;&gt;From document corpus&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#from-result-documents-serp&quot;&gt;From result documents (SERP)&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#completion-lookup-methods&quot;&gt;Completion lookup methods&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#prefix-search&quot;&gt;Prefix search&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#typo-tolerant-prefix-search&quot;&gt;Typo-tolerant Prefix search&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#substring-search&quot;&gt;Substring search&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#conjunctive-search&quot;&gt;Conjunctive search&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#sliding-window-completion&quot;&gt;Sliding window completion&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#sliding-window-completion-expansion&quot;&gt;Sliding window completion expansion&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#symspellcomplete&quot;&gt;SymSpellComplete&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#qac-using-language-models&quot;&gt;QAC using language models&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#query-spelling-correction&quot;&gt;Query spelling correction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#combining-spelling-correction-and-completion&quot;&gt;Combining spelling correction and completion&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#ui-integration-of-completions&quot;&gt;UI integration of completions&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#ghosting&quot;&gt;Ghosting&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#instant-search&quot;&gt;Instant search&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#completions-and-search-operators&quot;&gt;Completions and search operators&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#completions-tokenizers-and-stemming&quot;&gt;Completions, tokenizers and stemming&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#serialization-and-compression-of-completion-lists&quot;&gt;Serialization and compression of completion lists&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#removing-outdated-suggestions&quot;&gt;Removing outdated completions&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#scaling-challenges&quot;&gt;Scaling challenges&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tests-what-to-measure&quot;&gt;Tests: What to measure?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#benchmarks&quot;&gt;Benchmarks&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#usage&quot;&gt;Usage&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#symspellcomplete-standalone&quot;&gt;SymSpellComplete library (standalone)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#seekstorm-library-integrated-symspellcomplete&quot;&gt;SeekStorm library (integrated SymSpellComplete)&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#seekstorm-server-rest-api-integrated-symspellcomplete&quot;&gt;SeekStorm server REST API (integrated SymSpellComplete)&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#availability&quot;&gt;Availability&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;problem-statement-and-requirements&quot;&gt;Problem statement and requirements&lt;/h2&gt;

&lt;h3 id=&quot;why-query-completion&quot;&gt;Why query completion?&lt;/h3&gt;

&lt;p&gt;Providing the user with query completions while typing has many benefits:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;it &lt;strong&gt;saves time&lt;/strong&gt;, &lt;strong&gt;prevents and corrects spelling mistakes&lt;/strong&gt;,&lt;/li&gt;
  &lt;li&gt;makes sure &lt;strong&gt;queries are aligned with index content&lt;/strong&gt;,&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;helps the user to formulate queries&lt;/strong&gt; if he is unsure about the terms, their spelling or the content of the index.&lt;/li&gt;
  &lt;li&gt;query completions help to prevent queries that lead to &lt;strong&gt;zero results&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://dl.acm.org/doi/abs/10.1145/1321440.1321556&quot;&gt;Feuer et al.&lt;/a&gt; analyzed more than 1.5 million queries from search logs of a commercial search engine and found that query suggestions accounted for roughly 30% of all the queries indicating the important role played by query suggestions in modern information retrieval systems. Furthermore, &lt;a href=&quot;https://dl.acm.org/doi/pdf/10.1145/1571941.1572006&quot;&gt;Kelly et al.&lt;/a&gt; observed that the use of offered query suggestions is more for difficult topics, i.e., topics about which users have little knowledge to formulate good queries.&lt;/p&gt;

&lt;p&gt;Those numbers may vary, depending on the coverage of completions, their quality, the domain and changing user behavior. You should ultimately always do your own experiments and measurements with your own data and users.&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;implementing QAC at scale&lt;/strong&gt; also comes with many challenges: how to &lt;strong&gt;collect, count and select the completions&lt;/strong&gt;, with &lt;strong&gt;low memory requirement&lt;/strong&gt;, &lt;strong&gt;low performance impact&lt;/strong&gt;, and &lt;strong&gt;high relevance&lt;/strong&gt;. 
And how to &lt;strong&gt;rank and serve them to the user&lt;/strong&gt; with &lt;strong&gt;low latency&lt;/strong&gt;, even for &lt;strong&gt;large indices&lt;/strong&gt; and &lt;strong&gt;many concurrent users&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Could we get away with simply adding a library like &lt;a href=&quot;https://github.com/wolfgarbe/PruningRadixTrie&quot;&gt;PruningRadixTrie&lt;/a&gt; and feeding it with a word frequency list like those from &lt;a href=&quot;https://github.com/wolfgarbe/SymSpell?tab=readme-ov-file#frequency-dictionary&quot;&gt;SymSpell&lt;/a&gt;? Sure, we can - but we would sacrifice a lot of functionality we could achieve otherwise:&lt;/p&gt;

&lt;h3 id=&quot;desired-functionality&quot;&gt;Desired functionality&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;multi-term completions&lt;/li&gt;
  &lt;li&gt;no discrepancy between completions and indexed document content&lt;/li&gt;
  &lt;li&gt;support for new and domain-specific terms&lt;/li&gt;
  &lt;li&gt;support for index specific completions and their rankings&lt;/li&gt;
  &lt;li&gt;language independence&lt;/li&gt;
  &lt;li&gt;prefix or substring lookup&lt;/li&gt;
  &lt;li&gt;typo-tolerant completion
    &lt;ul&gt;
      &lt;li&gt;deal with spelling errors in both complete and incomplete terms, including the first letter&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;word-order tolerant completion
    &lt;ul&gt;
      &lt;li&gt;identify completions where all the query terms appear as prefixes of some of the terms of the completions, regardless their order.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;score completions by word and n-gram frequency, derived from the corpus, for high relevancy.&lt;/li&gt;
  &lt;li&gt;low resource impact of completion generation, storage, and lookup: RAM, disc, processor, IO&lt;/li&gt;
  &lt;li&gt;fast lookup time&lt;/li&gt;
  &lt;li&gt;dynamic, self-learning from a stream of documents as opposed to immutable one-time batch generation&lt;/li&gt;
  &lt;li&gt;scaling: preventing unlimited growth of completions lists and resource consumption as the index grows&lt;/li&gt;
  &lt;li&gt;Integration of completions into the UI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On of the biggest challenges in search is the &lt;strong&gt;gap between query-term space and document-term space&lt;/strong&gt;. 
Users will always blame our search or our content, and not their deficiencies to search.
We should give the use all assistance possible to close that gap, in order not not lose our users and/or revenue.&lt;/p&gt;

&lt;h2 id=&quot;integral-functionality-vs-external-component&quot;&gt;Integral functionality vs. external component&lt;/h2&gt;

&lt;p&gt;More functionality usually comes with more complexity (and bulk if it is not needed). 
Having a bare-bone search library, which is both performant and easy to understand, 
while you can add any functionality you want to your pipeline with external components of your choice, has a beauty of its own.&lt;/p&gt;

&lt;p&gt;In search, high-performance core technology is paramount, as is keeping things simple, and preventing complexity -
but integrating more building blocks makes it more accessible,  appealing to a wider audience, reduces the time to market,
and keeps the overall system even less complex despite added functionality, given the following preconditions&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;functionality that the user &lt;strong&gt;almost always anyway needs&lt;/strong&gt;, otherwise requiring additional pre- or post-processing components.&lt;/li&gt;
  &lt;li&gt;that the functionality is &lt;strong&gt;non-trivial to add and integrate&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;that the functionality benefits from a &lt;strong&gt;deeper integration&lt;/strong&gt; with the core indexing and search technology (e.g. using the tokenizer, plugging into commit, multi-tenancy and per index customization …).&lt;/li&gt;
  &lt;li&gt;there are &lt;strong&gt;no external components available&lt;/strong&gt;, that check all the boxes of the desired functionality listed above.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Challenges&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Using the same corpus for query spelling correction (dictionary generation) and query completion (completion list generation) as for indexing and search, to prevent suggesting queries that lead to zero results.&lt;/li&gt;
  &lt;li&gt;Using the same tokenizer for query spelling correction (dictionary generation, lookup) and query completion (completion list generation, lookup) like for indexing and search.&lt;/li&gt;
  &lt;li&gt;Take into account CJK word segmentation for query spelling correction and query completion.&lt;/li&gt;
  &lt;li&gt;Allow and preserve query operator chars like + - “” during query spelling correction and completion.&lt;/li&gt;
  &lt;li&gt;Do not use NOT (-) terms for query completion, neither for input prefix, nor for output suggestions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Phrase completions - Allow, preserve and complete phrase chars “” during query spelling correction &amp;amp; completion.&lt;/em&gt;&lt;br /&gt;
&lt;img src=&quot;..\assets\images\completions7.png&quot; alt=&quot;Phrase completions&quot; /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Currently, query correction/completion supports phrases “”, but is disabled if +- operators are used,  or if a opening quote is used after the first term, or if a closing quote is used before the last term.&lt;/p&gt;

&lt;p&gt;Reporting from my experience, having word frequency lists (uni-gram and bi-gram), spelling correction and auto completion libraries readily available, and as author, deep knowledge of those libraries as well as of the search engine library, it took several weeks of research, experimenting, implementing, integrating until the results met my expectations and the desired functionality. 
&lt;strong&gt;It is always more complex than you think&lt;/strong&gt; in the beginning, and we wanted to &lt;strong&gt;remove the need to reinvent the wheel&lt;/strong&gt; for a &lt;strong&gt;functionality that almost everyone using a search engine benefits from&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Just by reading the table of contents of this blog post you probably already know, that implementing query auto-completion yourself, even by using available libraries, would be a substantial endeavor.&lt;/p&gt;

&lt;p&gt;Sure, the last percents of perfection in your domain you get only with a fully customized pipeline, including deep integration into the search engine codebase, specifically designed for your users, for your data, for your use case, but that requires a significant amount time, budget, and expertise.&lt;/p&gt;

&lt;p&gt;For many users, a &lt;strong&gt;turn-key solution&lt;/strong&gt; that just works, at no extra cost, is preferable, at least for the start.&lt;/p&gt;

&lt;h2 id=&quot;query-and-completion-lengths&quot;&gt;Query and completion lengths&lt;/h2&gt;

&lt;p&gt;Query lengths hugely depends on the type of search e.g. (e-commerce vs. web), the domain (sport, entertainment, legal, scientific research), and the experience of the searcher.
Currently, most of the queries consist of 4 or less terms, but with the &lt;a href=&quot;https://searchengineland.com/keyword-query-length-insights-445376&quot;&gt;advent of LLM that is changing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;While we would like to provide query completions for any number of query terms the user enters, the resource consumption required to extract completions &lt;strong&gt;grows exponentially with the number of query terms&lt;/strong&gt;.&lt;br /&gt;
A limit of n=3 for the number of consecutive terms (unigrams, bigrams, trigrams) to extract as completion candidates is the maximum we can afford in terms of resource consumption.&lt;br /&gt;
But we can mitigate this limitation with a &lt;a href=&quot;#sliding-window-completion&quot;&gt;Sliding window completion&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;completion-data-sources&quot;&gt;Completion data sources&lt;/h2&gt;

&lt;p&gt;There are three approaches to obtain and distill query completion data:&lt;/p&gt;

&lt;h3 id=&quot;from-query-logs&quot;&gt;From query logs&lt;/h3&gt;

&lt;p&gt;Deriving completions from a query log is the most popular approach, with both pros and cons:&lt;/p&gt;

&lt;p&gt;Benefits&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;user curated: real users with quantifiable interest in those queries&lt;/li&gt;
  &lt;li&gt;usage-driven vs. content-driven suggestion ranking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Drawbacks&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;logs with invalid queries lead to invalid completions: misspelled terms, query doesn’t return results because there are no matching documents indexed.&lt;/li&gt;
  &lt;li&gt;outdated query logs, missing completions: query popularity, missing new or domain specific terms and queries. 
Often suggestions are created once, and not updated or only with delay, when new documents with new terms are indexed.&lt;/li&gt;
  &lt;li&gt;difficult to obtain:  representative and statistically sufficient query logs, especially for new and domain specific indices with limited prior usage.&lt;/li&gt;
  &lt;li&gt;privacy concerns: see https://en.wikipedia.org/wiki/AOL_search_log_release&lt;/li&gt;
  &lt;li&gt;divergence between completion and indexed content: completions might be suggested for which no matching documents can be found in the index.&lt;/li&gt;
  &lt;li&gt;due to the long-tail nature of queries, most of the queries have never been seen before. This also means for most queries completion solely based of query logs won’t work.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See &lt;a href=&quot;https://arxiv.org/abs/2411.04129&quot;&gt;AmazonQAC: A Large-Scale, Naturalistic Query Autocomplete Dataset&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;from-document-corpus&quot;&gt;From document corpus&lt;/h3&gt;

&lt;p&gt;Deriving completions from indexed documents is an alternate approach, also with both pros and cons.&lt;/p&gt;

&lt;p&gt;There is an interesting paper &lt;a href=&quot;https://www.researchgate.net/publication/221300316_Query_suggestions_in_the_absence_of_query_logs&quot;&gt;Query Suggestions in the Absence of Query Logs&lt;/a&gt; by Sumit Bhatia, Debapriyo Majumdar, Prasenjit Mitra that introduces the general idea of deriving query completions by extracting n-grams (uni-grams, bi-grams and tri-grams) from the document corpus instead from the usual query log. 
Using the extracted set of completion n-grams, the paper also investigates the ranking and precision of query completions generated by different query suggestion methods.&lt;/p&gt;

&lt;p&gt;Unfortunately, both the principal drawbacks of the approach and the challenges when scaling it to production are not discussed.&lt;/p&gt;

&lt;h4 id=&quot;benefits&quot;&gt;Benefits&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;The completions are automatically derived in real-time from indexed documents, not from a query log:&lt;/li&gt;
  &lt;li&gt;works, even if no query log is available, especially for domain-specific, newly created indices or few users.&lt;/li&gt;
  &lt;li&gt;works for new or domain-specific terms.&lt;/li&gt;
  &lt;li&gt;allows out-of-the-box domain specific suggestions&lt;/li&gt;
  &lt;li&gt;prevents inconsistencies between completions and index content. 
Query logs contains invalid queries: because its sourced from a different index or because users don’t know the content of your index..&lt;/li&gt;
  &lt;li&gt;Works for the long tail of queries, that never made it to a log.&lt;/li&gt;
  &lt;li&gt;content-driven vs. usage-driven suggestion ranking.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;challenges&quot;&gt;Challenges&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;there are no consideration about &lt;strong&gt;scaling&lt;/strong&gt; the approach &lt;strong&gt;for large indices&lt;/strong&gt;, and the challenges that come with it,&lt;/li&gt;
  &lt;li&gt;RAM, disk and processor consumption and limits,&lt;/li&gt;
  &lt;li&gt;n-gram extraction performance,&lt;/li&gt;
  &lt;li&gt;lookup performance,&lt;/li&gt;
  &lt;li&gt;completeness of suggestions,&lt;/li&gt;
  &lt;li&gt;effective storage and compression of completions,&lt;/li&gt;
  &lt;li&gt;measures to reduce resource consumption (term frequency thresholds, capping the number of stored completions), while achieving a good cost (processor, disk space, RAM consumptions) vs. precision and recall ratio,&lt;/li&gt;
  &lt;li&gt;realtime updates and availability of suggestions from a document stream as opposed to a one-time batch processing leading to static immutable completions,&lt;/li&gt;
  &lt;li&gt;how to deal with non-uniformly distributed terms and n-grams, e.g. new products occurring late, or only within a specific range of documents&lt;/li&gt;
  &lt;li&gt;typo-tolerance, especially when typos at the beginning of the word prevent the use of tries.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;drawbacks&quot;&gt;Drawbacks&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;There are many term combinations created that will be never searched&lt;/strong&gt;, making it inefficient both for creation time, resource consumption and storage requirements, and difficult to scale for large indices. Brute force is expensive. The challenge is similar to writing an abstract from a large document or deciding which words and passages to highlight in bold.&lt;/li&gt;
  &lt;li&gt;Only completions are created and counted, that appear as &lt;strong&gt;consecutive terms&lt;/strong&gt; within a maximum distance of 3 (trigrams) within the indexed documents. Most users are trained to enter only those terms that make the essence of the question. Those terms can be non-consecutive, because natural language is verbose, filled with many words caused by grammar rules. But sometimes queries refer to terms that are accepted to appear in different places in the document, like the query &lt;code class=&quot;highlighter-rouge&quot;&gt;louvre ticket price&lt;/code&gt; - while in the document the terms appear as &lt;code class=&quot;highlighter-rouge&quot;&gt;Louvre ... Location ... Ticket ... Where to buy ... Price ...&lt;/code&gt;.
Sometimes, but not always, those completions will be anyway created, because they appear together in close proximity in other documents. And deriving completions from all term combinations that appear anywhere within a documents (beyond those that are consecutive) is just not feasible because of the amount of combinations that would be created and the difficulty to automatically distinguish between combinations that are useful and those that are just a waste of time and space.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Significant time and space complexity&lt;/strong&gt;: A quick baseline experiment shows, that &lt;strong&gt;deriving and counting all unique unigram, bigram and trigram completions&lt;/strong&gt; from a &lt;strong&gt;5,032,105 document Wikipedia corpus&lt;/strong&gt; with a naive hashmap approach in the tokenizer lasted &lt;strong&gt;461 minutes&lt;/strong&gt;, while the &lt;strong&gt;indexing alone&lt;/strong&gt; without generating completions was done within &lt;strong&gt;3 minutes&lt;/strong&gt;. A &lt;strong&gt;cost of 2 orders of magnitude&lt;/strong&gt; is certainly not acceptable. So we have to come up with a fundamentally better.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;E.g. with the document &lt;code class=&quot;highlighter-rouge&quot;&gt;A quick baseline experiment shows that deriving and counting all unique unigrams is inefficient.&lt;/code&gt;,&lt;br /&gt;
the following generated n-gram completions are &lt;strong&gt;unlikely queries&lt;/strong&gt; to be entered by an user:  &lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;a quick&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;experiment shows&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;experiment shows that&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;shows that&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;shows that deriving&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;that deriving&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;that deriving and&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;more &lt;strong&gt;likely queries&lt;/strong&gt; would be:&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;deriving unigrams&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;deriving unigrams inefficient&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;counting unigrams&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;counting unigrams inefficient&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Additional considerations&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Only completions are created and counted, that appear as &lt;strong&gt;consecutive terms&lt;/strong&gt; within a maximum distance of 3 (unigrams, bigrams, trigrams) within the indexed documents, in order to limit the RAM and disk consumption.
The number and the length of extracted n-grams grows linearly with n, but the number of &lt;strong&gt;unique&lt;/strong&gt; n-grams to store and search through grows exponentially with n.&lt;/li&gt;
  &lt;li&gt;The maximum number of completion entries to be collected can be specified.&lt;/li&gt;
  &lt;li&gt;By specifying from which fields of the documents the completions should be derived, e.g. from title field, product name field, the relevancy (precision) of completions can be increased, at the cost of completeness (recall).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Usually every field has a specific meaning or purpose, which we could understand as human labeling. It doesn’t make sense to lose that information away by throwing all fields in a bag of words, only to subsequently trying to recover again that meaning with global statistics. We could also use extra boost / scoring factors per field.&lt;/p&gt;

&lt;h3 id=&quot;from-result-documents-serp&quot;&gt;From result documents (SERP)&lt;/h3&gt;

&lt;p&gt;Another approach is extracting completions from previous search results, given that we are using instant search where we return results for every key stroke, or at least every term that has been completely entered.. 
If we search for “data encryption algor…” there has been previously the query “data encryption”. In the search results of that query we can analyze, what terms are following the matches of the query terms within each returned document. We are extracting completions on-the-fly from previously returned documents.&lt;/p&gt;

&lt;p&gt;Again, there are pros and cons:&lt;/p&gt;

&lt;p&gt;Benefits&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;no extraction preprocessing of query log or corpus required&lt;/li&gt;
  &lt;li&gt;no storage of completion lists required&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Drawbacks&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;for small result sets the extracted suggestions will be limited. The relevance of search results doesn’t ensure the relevancy and broadness of completions.&lt;/li&gt;
  &lt;li&gt;for more complete and relevant suggestions we need to increase the result set of previous queries, introducing extra query latency and resource consumption.&lt;/li&gt;
  &lt;li&gt;frequency data to small to reliably rank completions.&lt;/li&gt;
  &lt;li&gt;extraction of completion from a large number of large result documents introduces extra suggestion latency.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;completion-lookup-methods&quot;&gt;Completion lookup methods&lt;/h2&gt;

&lt;p&gt;Once we have derived the completions, either form query logs or document corpus, we need to to lookup the matching completions for a given prefix or substring of an incomplete query.
There are many feasible approaches, differing by result type, compactness and lookup time:&lt;/p&gt;

&lt;h3 id=&quot;prefix-search&quot;&gt;Prefix search&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://seekstorm.com/blog/pruning-radix-trie/&quot;&gt;Pruning radix trie&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Radix_tree&quot;&gt;Radix trie / patricia trie&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.range&quot;&gt;BTreeMap with ranges&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Ternary_search_tree&quot;&gt;Ternary search tree&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;other &lt;a href=&quot;https://en.wikipedia.org/wiki/Trie&quot;&gt;Tries&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/TopKCompletion.pdf&quot;&gt;Completion Trie (CT), Score-Decomposed Trie (SDT), and RMQ Trie (RT)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://validark.dev/DynSDT/&quot;&gt;DynSDT&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Drawbacks of all tree/trie-based prefix-search algorithms:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Not typo-tolerant&lt;/li&gt;
  &lt;li&gt;Not word-order tolerant&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we reduce our requirements to &lt;strong&gt;single term completions&lt;/strong&gt;, e.g. to completions of the &lt;strong&gt;last incomplete term of a query&lt;/strong&gt;, we don’t need to generate a completion list first, and we simply can get away with a single-term frequency dictionary, like &lt;a href=&quot;https://github.com/wolfgarbe/SymSpell?tab=readme-ov-file#frequency-dictionary&quot;&gt;those used by SymSpell&lt;/a&gt; or those created in SeekStorm (if spelling correction is enabled) from the indexed documents.&lt;/p&gt;

&lt;p&gt;The drawback would be twofold:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;we miss the convenience and time saving of multi-term completions&lt;/li&gt;
  &lt;li&gt;the ranking of single term completions is less relevant, as we miss the co-occurrence probabilities of multi-term completions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;typo-tolerant-prefix-search&quot;&gt;Typo-tolerant Prefix search&lt;/h3&gt;

&lt;p&gt;The idea is to combine prefix search via one of the trie data structures with the same &lt;a href=&quot;https://seekstorm.com/blog/1000x-spelling-correction/&quot;&gt;Symmetric Delete algorithm&lt;/a&gt; that is used in SymSpell.
Basically, instead of prefixes and terms, we use deletes of prefixes and terms.&lt;/p&gt;

&lt;h3 id=&quot;substring-search&quot;&gt;Substring search&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://swtch.com/~rsc/regexp/regexp4.html&quot;&gt;Indexed Regular Expression Search&lt;/a&gt; based on character-wise 3-grams (trigrams), &lt;a href=&quot;https://codesearch.debian.net/research/bsc-thesis.pdf&quot;&gt;more&lt;/a&gt;, &lt;a href=&quot;https://github.com/google/codesearch&quot;&gt;more&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A drawback of trigram-based substring search is the much larger index size, that is increased by factor L, with L being the average word length.&lt;/p&gt;

&lt;h3 id=&quot;conjunctive-search&quot;&gt;Conjunctive search&lt;/h3&gt;

&lt;p&gt;Conjunctive search identifies completions where all the query terms appear as prefixes of some of the terms of the completions, &lt;strong&gt;regardless their order&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/2005.06213&quot;&gt;Efficient and Effective Query Auto-Completion&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://people.eng.unimelb.edu.au/ammoffat/abstracts/kmz17adcs.pdf&quot;&gt;A Taxonomy of Query Auto Completion Modes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;sliding-window-completion&quot;&gt;Sliding window completion&lt;/h3&gt;

&lt;p&gt;Only completions were created that appear as &lt;strong&gt;consecutive terms&lt;/strong&gt; within a &lt;strong&gt;maximum distance of 3&lt;/strong&gt; (unigrams, bigrams, trigrams) within the indexed documents, in order to limit the RAM and disk consumption.&lt;br /&gt;
To provide &lt;strong&gt;completions with n &amp;gt; 3 terms&lt;/strong&gt;, we use a &lt;strong&gt;sliding window&lt;/strong&gt; of the &lt;strong&gt;last three terms&lt;/strong&gt; (the last term might be incomplete, any trailing space is counted as term) of the query string for lookup with prefix search within the collection of trigram completions. Then the first n-3 terms of the query are concatenated with each of the trigram completions found to create long completion &lt;strong&gt;candidates&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Validation&lt;/strong&gt;&lt;br /&gt;
We need to &lt;strong&gt;verify whether the completion candidates are valid queries&lt;/strong&gt;, e.g. by checking whether they indeed are returning results. The number of results per candidate can also be used for ranking the suggestions.&lt;/p&gt;

&lt;p&gt;A less expensive, but also less reliable approach is to check whether all previous 3-gram searches (of complete terms) that were encountered during typing did return results.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sliding window completion &amp;gt; 3 terms&lt;/em&gt;&lt;br /&gt;
&lt;img src=&quot;..\assets\images\completions8.png&quot; alt=&quot;Sliding window completion &amp;gt; 3 terms&quot; /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3 id=&quot;sliding-window-completion-expansion&quot;&gt;Sliding window completion expansion&lt;/h3&gt;

&lt;p&gt;Sometimes we do get not enough suggestions (&lt;code class=&quot;highlighter-rouge&quot;&gt;suggestions.len() &amp;lt; QueryRewriting::SearchSuggest{... length}&lt;/code&gt;) for a partial input query.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: &lt;strong&gt;without&lt;/strong&gt; sliding window completion expansion:&lt;/em&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;united states ol&lt;/code&gt; -&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;united states olympic&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\completions11.png&quot; alt=&quot;without sliding window completion expansion&quot; /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;The reason for the limited results is that we search with a partial query of three terms only within trigrams.&lt;/p&gt;

&lt;p&gt;If we detect that the number of returned suggestions is &amp;lt; length, then we add an an &lt;strong&gt;additional completion step&lt;/strong&gt; with a &lt;strong&gt;different input&lt;/strong&gt;. 
We take the last two terms of the top trigram completion + space as input, to get more completions for long queries.&lt;br /&gt;
We are using the same principle as described in sliding window completion above, with the difference that now we search with the &lt;strong&gt;last two parts plus a trailing space of the first trigram completion&lt;/strong&gt;, 
while above we searched with the &lt;strong&gt;last three parts of the query&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: additional completion step&lt;/em&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;states olympic &lt;/code&gt; -&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;united '+'olympic trials&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;united &lt;/code&gt;+&lt;code class=&quot;highlighter-rouge&quot;&gt;states olympic curling&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;united &lt;/code&gt;+&lt;code class=&quot;highlighter-rouge&quot;&gt;states olympic basketball&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;united &lt;/code&gt;+&lt;code class=&quot;highlighter-rouge&quot;&gt;states olympic committee&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;returned suggestions&lt;/strong&gt; are &lt;strong&gt;not added&lt;/strong&gt; to the end of the suggestion list, but &lt;strong&gt;inserted after the completion that was used as input&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: the final results after sliding window completion expansion:&lt;/em&gt;&lt;br /&gt;
&lt;code class=&quot;highlighter-rouge&quot;&gt;united states ol&lt;/code&gt; -&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;united states olympic&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;united states olympic trials&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;united states olympic curling&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;united states olympic basketball&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;united states olympic committee&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\completions10.png&quot; alt=&quot;Sliding window completion expansion&quot; /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Why don’t we start with the two last terms of the query from the beginning? The more terms we use as input the more likely the completions will match our intension. 
We only fall back if our first attempt doesn’t return enough results. Additionally, the last two terms from the top completion are more specific then the last two terms from the query where the last term is incomplete.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Another example: &lt;strong&gt;without&lt;/strong&gt; sliding window completion expansion&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\completions6.png&quot; alt=&quot;without sliding window completion expansion&quot; /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Another example: &lt;strong&gt;with&lt;/strong&gt; sliding window completion expansion&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\completions12.png&quot; alt=&quot;without sliding window completion expansion&quot; /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3 id=&quot;symspellcomplete&quot;&gt;SymSpellComplete&lt;/h3&gt;

&lt;p&gt;We are combining query spelling correction, typo-tolerant Prefix search, Conjunctive search, and a sliding window for completion, and the &lt;a href=&quot;https://github.com/wolfgarbe/SymSpell?tab=readme-ov-file#compound-aware-multi-word-spelling-correction&quot;&gt;lookup_compound method&lt;/a&gt; from SymSpell for spelling correction.&lt;/p&gt;

&lt;h3 id=&quot;qac-using-language-models&quot;&gt;QAC using language models&lt;/h3&gt;

&lt;p&gt;Using language models for Query auto-completion is an promising approach.&lt;br /&gt;
While lexical query auto-completion tries to foresee the query the user is about to type, language model base query auto-completion tries to suggest queries that are different from what the user is going to type, 
but better suited to the identified intention of the user, based on the actual index content.&lt;/p&gt;

&lt;p&gt;We discarded this idea for now for the following reasons:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Language models are language and domain specific, making it expensive in a multi-language, multi-domain, multi-tenancy environment.&lt;/li&gt;
  &lt;li&gt;Language models are time consuming to update.&lt;/li&gt;
  &lt;li&gt;Language models add significant complexity, processor load and latency, especially under high concurrent load.&lt;/li&gt;
  &lt;li&gt;Increased recall, but at the cost of decreased precision.&lt;/li&gt;
  &lt;li&gt;Problematic for misspelled input.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It boils down to the choice between giving up the last 10% of suggestion quality and completeness vs. orders of magnitude latency, system complexity, development time and production cost.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.amazon.science/publications/a-product-aware-query-auto-completion-framework-for-e-commerce-search-via-retrieval-augmented-generation-method&quot;&gt;A product-aware query auto-completion framework for e-commerce search via retrieval-augmented generation method&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1909.00599&quot;&gt;Subword Language Model for Query Auto-Completion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;challenges-1&quot;&gt;Challenges&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;How to merge and rank corrections vs. completions, if both are available?&lt;/li&gt;
  &lt;li&gt;How to rank between unigrams/bigram/trigrams? Higher order n-gram counts are always lower compared with lower-order n-grams they are prefixed with. 
But perhaps the lower order n-gram isn’t a complete query and we should prefer the higher order n-gram that is? 
Between higher- and lower order n-grams with different prefixes it is even harder to decide. Do we need a correction factor for n-gram order?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;query-spelling-correction&quot;&gt;Query spelling correction&lt;/h2&gt;

&lt;p&gt;SeekStorm’s query spelling correction is using the &lt;a href=&quot;https://github.com/wolfgarbe/symspell_rs&quot;&gt;SymSpell library&lt;/a&gt;, based on the Symmetric Delete spelling correction algorithm.&lt;/p&gt;

&lt;p&gt;WE use the lookup_compound method for the spelling correction of multi-term query strings that handles three cases:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;mistakenly inserted space into a correct term led to two incorrect terms: &lt;code class=&quot;highlighter-rouge&quot;&gt;hels inki&lt;/code&gt; -&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;helsinki&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;mistakenly omitted space between two correct terms led to one incorrect combined term: &lt;code class=&quot;highlighter-rouge&quot;&gt;modernart&lt;/code&gt; -&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;modern art&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;multiple independent input terms with/without spelling errors: &lt;code class=&quot;highlighter-rouge&quot;&gt;cinese indastrialication&lt;/code&gt; -&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;chinese industrialization&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Symmetric Delete spelling correction algorithm reduces the complexity of edit candidate generation and dictionary lookup for a given Damerau-Levenshtein distance. 
It is six orders of magnitude faster (than the standard approach with deletes + transposes + replaces + inserts) and language independent.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Query spelling correction&lt;/em&gt;&lt;br /&gt;
&lt;img src=&quot;..\assets\images\correction3.png&quot; alt=&quot;Query spelling correction&quot; /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;combining-spelling-correction-and-completion&quot;&gt;Combining spelling correction and completion&lt;/h2&gt;

&lt;p&gt;The combination of &lt;strong&gt;query spelling correction&lt;/strong&gt; and query &lt;strong&gt;auto-completion&lt;/strong&gt; (QAC) can be challenging.
Currently we use the following straight forward approach:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;We use the &lt;strong&gt;query as input&lt;/strong&gt; for the &lt;strong&gt;query auto-completion&lt;/strong&gt; (QAC).&lt;/li&gt;
  &lt;li&gt;If &lt;strong&gt;no completions&lt;/strong&gt; are returned then we &lt;strong&gt;switch&lt;/strong&gt; to &lt;strong&gt;query spelling correction&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;If a &lt;strong&gt;spelling correction was found&lt;/strong&gt;, then we use the &lt;strong&gt;corrected query as input&lt;/strong&gt; for a second &lt;strong&gt;query auto-completion&lt;/strong&gt; (QAC).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An alternative approach would be simpler, but also more prone to errors:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;We use &lt;strong&gt;all complete query terms as input&lt;/strong&gt; for the &lt;strong&gt;query spelling correction&lt;/strong&gt;, and &lt;strong&gt;remember the incomplete last term&lt;/strong&gt; (enter or space make a term complete).&lt;/li&gt;
  &lt;li&gt;We &lt;strong&gt;concatenate&lt;/strong&gt; the &lt;strong&gt;result of the query spelling correction&lt;/strong&gt; and the &lt;strong&gt;incomplete last term&lt;/strong&gt; as input for &lt;strong&gt;query auto-completion&lt;/strong&gt; (QAC).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While the second approach is simpler, it is also but also more prone to errors:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;If the spelling correction of the query returns an incorrect result, then the subsequent completion will also return incorrect or no completions.&lt;/li&gt;
  &lt;li&gt;We have to consider
    &lt;ul&gt;
      &lt;li&gt;the probabilities of a required spelling correction,&lt;/li&gt;
      &lt;li&gt;the probabilities of a incorrect spelling correction result,&lt;/li&gt;
      &lt;li&gt;the probabilities of an required completion,&lt;/li&gt;
      &lt;li&gt;the additional latency of a spelling correction,&lt;/li&gt;
      &lt;li&gt;the additional latency of a query completion,&lt;/li&gt;
      &lt;li&gt;is the dictionary for spelling correction is complete or limited,&lt;/li&gt;
      &lt;li&gt;is the list of completions is complete or limited.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;We almost always need to complete the query, while &lt;strong&gt;spelling errors are relatively rare&lt;/strong&gt;.&lt;br /&gt;
When we start with query completion &lt;strong&gt;it won’t introduce errors&lt;/strong&gt;, and at the same time we can &lt;strong&gt;avoid 90% of spelling correction calls&lt;/strong&gt; (no additional latency, no chance of introducing errors).&lt;br /&gt;
If a spelling correction exists this indicates that the query is spelled correctly, allowing us to sidestep spelling correction.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;completions-of-corrected-query&quot;&gt;Completions of corrected query&lt;/h3&gt;

&lt;p&gt;If we have found a correction of a misspelled query we can repeat the failed completion attempt, this time with the corrected query as input.&lt;br /&gt;
Of course, we have to make sure to prevent an endless loop (of unsuccessful completions and corrections).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Completion of corrected query&lt;/em&gt;&lt;br /&gt;
&lt;img src=&quot;..\assets\images\correction4.png&quot; alt=&quot;Completions of corrected query&quot; /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;ui-integration-of-completions&quot;&gt;UI integration of Completions&lt;/h2&gt;

&lt;h3 id=&quot;ghosting&quot;&gt;Ghosting&lt;/h3&gt;
&lt;p&gt;Ghosting is the process of &lt;strong&gt;predicting, auto-completing and highlighting a user’s intended text input inline&lt;/strong&gt; i.e., within the search box. 
Ghosting increases the acceptance of offered suggestions, reduces misspelled searches, and improves sales.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.amazon.science/publications/ghosting-contextualized-query-auto-completion-on-amazon-search&quot;&gt;Ghosting: Contextualized Query Auto-Completion on Amazon Search&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;instant-search&quot;&gt;Instant search&lt;/h3&gt;

&lt;p&gt;During typing the incomplete query is automatically completed and the best suggestion is used as query for instant search, if the option &lt;code class=&quot;highlighter-rouge&quot;&gt;SearchRewrite&lt;/code&gt; is enabled.&lt;/p&gt;

&lt;p&gt;While immediately executing every partial query already counts as “instant search”, it becomes much more useful once it is combined with query auto-completion (QAC).&lt;br /&gt;
Then you are not only saving the final “Enter”, but you will see the final result much earlier, even if you have only typed a prefix.&lt;br /&gt;
This saves keystrokes, time, unnecessary searches of incomplete queries, and distracting the user with their irrelevant search results.&lt;/p&gt;

&lt;p&gt;It is useful to prevent searches of different prefixes leading to identical completions, because it is not guaranteed that the user stops typing, once the desired completion is displayed.&lt;br /&gt;
The UI frontend can simply cancel all queries where the new partial query is a prefix of last completed query, but only if the new partial query is longer than the previous one (accounting for delete or browser back button).&lt;br /&gt;
This eliminates any unnecessary frontend-backend communication.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Query auto-completion (QAC), ghosting, and instant search&lt;/em&gt;&lt;br /&gt;
&lt;img src=&quot;..\assets\images\completions9.png&quot; alt=&quot;Query auto-completion (QAC) and instant search&quot; /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;completions-and-search-operators&quot;&gt;Completions and search operators&lt;/h2&gt;

&lt;p&gt;While using query completions we need to preserve any entered query operators, as + - “”.&lt;/p&gt;

&lt;h2 id=&quot;completions-tokenizers-and-stemming&quot;&gt;Completions, tokenizers and stemming&lt;/h2&gt;

&lt;p&gt;Tokenizers and stemming influence influence how terms are stored and searched in the search index. They also influence how completions are extracted from the corpus.
We have to make sure that indexing, search, completion generation and completion lookup all are using the same transformation pipeline.&lt;/p&gt;

&lt;h2 id=&quot;serialization-and-compression-of-completion-lists&quot;&gt;Serialization and compression of completion lists&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;https://en.wikipedia.org/wiki/Incremental_encoding&lt;/li&gt;
  &lt;li&gt;https://en.wikipedia.org/wiki/Zstd&lt;/li&gt;
  &lt;li&gt;https://github.com/rkyv/rkyv?tab=readme-ov-file&lt;/li&gt;
  &lt;li&gt;https://en.wikipedia.org/wiki/Comma-separated_values&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;removing-outdated-completions&quot;&gt;Removing outdated completions&lt;/h2&gt;

&lt;p&gt;Often an index is not static, new documents are indexed, outdated documents are removed. This is a very typical for e-commerce search.
While new completions are covered, when they are anyway derived from newly indexed documents, for outdated we have to take one of the following extra measures:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;regularly, or after a certain time or number of deleted documents, re-generate all suggestions from all indexed documents. This is somewhat expensive and works only if fields not only index but also stored.&lt;/li&gt;
  &lt;li&gt;for each deleted document, generate all completions for this document, and decrease their count in the list of stored suggestions. If the count reaches 0, then remove the completion (and all longer n-grams containing this suggestion) from the stored list.&lt;/li&gt;
  &lt;li&gt;Let the user do the maintenance: if for a user query and their completions no results are found in the index, then this completion (and all longer n-grams containing this suggestion) are removed from the list of stored completions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;scaling-challenges&quot;&gt;Scaling challenges&lt;/h2&gt;

&lt;p&gt;Both correction dictionaries and completion list face scaling challenges.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The number of unique dictionary terms grows with the number of indexed documents according to &lt;a href=&quot;https://nlp.stanford.edu/IR-book/html/htmledition/heaps-law-estimating-the-number-of-terms-1.html&quot;&gt;Heap’s law&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;The number of unique deletes used in the symmetric delete spelling correction algorithm of SymSpell grows with the number of unique dictionary terms, multiplied with factor l=term length.&lt;/li&gt;
  &lt;li&gt;The number of n-gram completions grows exponentially with the number of unique dictionary terms.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Especially challenging is to keep dictionary terms, deletes and n-gram completions in RAM for fast lookup time. 
As RAM is limited, compared to the index residing on disk, we won’t be able to keep all dictionary terms, deletes and n-gram completions in RAM.&lt;/p&gt;

&lt;p&gt;Capping dictionary and completions at a certain limit during indexing will lead to several problems:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;New terms won’t it make to the dictionary, causing the spelling correction to identify it as spelling error and possibly causing a mis-correction to similar known terms.&lt;/li&gt;
  &lt;li&gt;Likewise, for newer terms appearing later in time during indexing no query completion will be available.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This are not specific problems of deriving the dictionary and completions from the indexed documents, but scaling problems that static dictionary and completion lists would face as well.&lt;/p&gt;

&lt;h2 id=&quot;tests-what-to-measure&quot;&gt;Tests: What to measure?&lt;/h2&gt;

&lt;p&gt;It is easy to get something going, but we want to compare our solution with alternative approaches and we want to see whether different measures can improve our result. 
We have to reliably measure how close the results our system is producing are to this what we would be expecting if if we would hand-craft it ourselves.&lt;/p&gt;

&lt;h3 id=&quot;creation-time&quot;&gt;Creation time&lt;/h3&gt;

&lt;p&gt;The time required to derive all significant completions up to a certain n-gram length from a document corpus of a given size.&lt;/p&gt;

&lt;h3 id=&quot;lookup-time&quot;&gt;Lookup time&lt;/h3&gt;

&lt;p&gt;The time to lookup matching completions for different query prefix lengths.&lt;/p&gt;

&lt;h3 id=&quot;ram-consumption&quot;&gt;RAM consumption&lt;/h3&gt;

&lt;p&gt;RAM consumed during creation and use, e.g. bei hash maps and tries.&lt;/p&gt;

&lt;h3 id=&quot;disc-space-consumption&quot;&gt;Disc space consumption&lt;/h3&gt;

&lt;p&gt;The disc space required to persistently store serialized completions.&lt;/p&gt;

&lt;h3 id=&quot;recall&quot;&gt;Recall&lt;/h3&gt;

&lt;p&gt;The percentage of queries with matching completions, preferably with queries logged from real users.&lt;/p&gt;

&lt;h3 id=&quot;precision&quot;&gt;Precision&lt;/h3&gt;

&lt;p&gt;The percentage of queries, for all prefixes of length 1..n, where the top-k completions we provided matched the final query.&lt;/p&gt;

&lt;h3 id=&quot;user-interaction&quot;&gt;User interaction&lt;/h3&gt;

&lt;p&gt;Measure the percentage of presented queries the user actually has interacted with.&lt;/p&gt;

&lt;h2 id=&quot;benchmarks&quot;&gt;Benchmarks&lt;/h2&gt;

&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;/h2&gt;

&lt;h3 id=&quot;symspellcomplete-standalone&quot;&gt;SymSpellComplete (standalone)&lt;/h3&gt;

&lt;h3 id=&quot;seekstorm-library-integrated-symspellcomplete&quot;&gt;SeekStorm library (integrated SymSpellComplete)&lt;/h3&gt;

&lt;h4 id=&quot;create-index&quot;&gt;Create Index&lt;/h4&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SpellingCorrection&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// The edit distance thresholds for suggestions: 1..2 recommended; higher values increase latency and memory consumption.&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max_dictionary_edit_distance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	
    &lt;span class=&quot;c&quot;&gt;/// Term length thresholds for each edit distance.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;///   None	max_dictionary_edit_distance for all terms lengths&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;///   Some([4])   max_dictionary_edit_distance for all terms lengths &amp;gt;= 4,&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;///   Some([2,8]) max_dictionary_edit_distance for all terms lengths &amp;gt;=2, max_dictionary_edit_distance +1 for all terms for lengths&amp;gt;=8&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;term_length_threshold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;/// Maximum number of completions to generate during indexing&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max_dictionary_entries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;QueryCompletion&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Maximum number of completions to generate during indexing&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// disabled if == 0&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max_completion_entries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IndexMetaObject&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Enable spelling correction for search queries using the SymSpell algorithm.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// SymSpell enables finding those spelling suggestions in a dictionary very fast with minimum Damerau-Levenshtein edit distance and maximum word occurrence frequency.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// When enabled, a SymSpell dictionary is incrementally created during indexing of documents and stored in the index.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// The spelling correction is not based on a generic dictionary, but on a domain specific one derived from your indexed documents (only indexed fields). &lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// This makes it language independent and prevents any discrepancy between corrected word and indexed content. &lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// The creation of an individual dictionary derived from the indexed documents improves the correction quality compared to a generic dictionary.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// An dictionary per index improves the privacy compared to a global dictionary derived from all indices.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// The dictionary is deleted when delete_index or clear_index is called.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Note: enabling spelling correction increases the index size, indexing time and query latency.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Default: None. Enable by setting CreateDictionary with values for max_dictionary_edit_distance (1..2 recommended) and optionally a term length thresholds for each edit distance. &lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// The higher the value, the higher the number of errors taht can be corrected - but also the memory consumption, lookup latency, and the number of false positives.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// ⚠️ In addition to the create_index parameter `meta.spelling_correction` you also need to set the parameter `query_rewriting` in the search method to enable it per query.&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;spelling_correction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SpellingCorrection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;/// Enable query completion for search queries&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_completion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;QueryCompletion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SchemaField&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;/// if both indexed=true and dictionary_source=true then the terms from this field are added to dictionary to the spelling correction dictionary.&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;/// if disabled, then a manually generated dictionary can be used: dictionary.csv&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dictionary_source&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;/// if both indexed=true and completion_source=true then the n-grams (unigrams, bigrams, trigrams) from this field are added to the auto-completion list.&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;/// if disabled, then a manually generated completion list can be used: completions.csv&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;completion_source&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;create_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;schema&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.await&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;search&quot;&gt;Search&lt;/h4&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;enum&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;QueryRewriting&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Query rewriting disabled, returns query results for query as-is, returns no suggestions for corrected or completed query.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// No performance overhead for spelling correction and suggestions.&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;#[default]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SearchOnly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Query rewriting disabled, returns query results for original query string, returns suggestions for corrected or completed query.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Additional latency for spelling suggestions.&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SearchSuggest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// Enable query correction, for queries with query string length &amp;gt;= threshold&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// A minimum length of 2 is advised to prevent irrelevant suggestions and results.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;correct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// The edit distance thresholds for suggestions: 1..2 recommended; higher values increase latency and memory consumption.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;distance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// Term length thresholds for each edit distance.&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;///   None	      max_dictionary_edit_distance for all terms lengths&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;///   Some([4])   max_dictionary_edit_distance for all terms lengths &amp;gt;= 4,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;///   Some([2,8]) max_dictionary_edit_distance for all terms lengths &amp;gt;=2, max_dictionary_edit_distance +1 for all terms for lengths&amp;gt;=8&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;term_length_threshold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// Enable query completions, for queries with query string length &amp;gt;= threshold, in addition to spelling corrections&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// A minimum length of 3 is advised to prevent irrelevant suggestions and results.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;complete&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// An option to limit maximum number of returned suggestions.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Query rewriting enabled, returns query results for spelling corrected or completed query string (=instant search), returns suggestions for corrected or completed query.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Additional latency for spelling correction and suggestions.&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SearchRewrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// Enable query correction, for queries with query string length &amp;gt;= threshold&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// A minimum length of 2 is advised to prevent irrelevant suggestions and results.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;correct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// The edit distance thresholds for suggestions: 1..2 recommended; higher values increase latency and memory consumption.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;distance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// Term length thresholds for each edit distance.&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;///   None	 max_dictionary_edit_distance for all terms lengths&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;///   Some([4])   max_dictionary_edit_distance for all terms lengths &amp;gt;= 4,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;///   Some([2,8]) max_dictionary_edit_distance for all terms lengths &amp;gt;=2, max_dictionary_edit_distance +1 for all terms for lengths&amp;gt;=8&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;term_length_threshold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// Enable query completions, for queries with query string length &amp;gt;= threshold, in addition to spelling corrections&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// A minimum length of 3 is advised to prevent irrelevant suggestions and results.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;complete&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// An option to limit maximum number of returned suggestions.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Search disabled, returns no query results, only returns suggestions for corrected or completed query.&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SuggestOnly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// Enable query correction, for queries with query string length &amp;gt;= threshold&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// A minimum length of 2 is advised to prevent irrelevant suggestions and results.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;correct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// The edit distance thresholds for suggestions: 1..2 recommended; higher values increase latency and memory consumption.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;distance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// Term length thresholds for each edit distance.&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;///   None	max_dictionary_edit_distance for all terms lengths&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;///   Some([4])   max_dictionary_edit_distance for all terms lengths &amp;gt;= 4,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;///   Some([2,8]) max_dictionary_edit_distance for all terms lengths &amp;gt;=2, max_dictionary_edit_distance +1 for all terms for lengths&amp;gt;=8&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;term_length_threshold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// Enable query completions, for queries with query string length &amp;gt;= threshold, in addition to spelling corrections&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// A minimum length of 3 is advised to prevent irrelevant suggestions and results.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;complete&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;/// An option to limit maximum number of returned suggestions.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;/// * `query_rewriting`: Enables query rewriting features such as spelling correction and suggestions.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;///    The spelling correction of multi-term query strings handles three cases:&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;///     1. mistakenly inserted space into a correct term led to two incorrect terms: `hels inki` -&amp;gt; `helsinki`&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;///     2. mistakenly omitted space between two correct terms led to one incorrect combined term: `modernart` -&amp;gt; `modern art`&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;///     3. multiple independent input terms with/without spelling errors: `cinese indastrialication` -&amp;gt; `chinese industrialization`&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;///    See QueryRewriting enum for details.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;///    ⚠️ In addition to setting the query_rewriting parameter per query, the incremental creation of the Symspell dictionary during the indexing of documents has to be enabled via the create_index parameter `meta.spelling_correction`.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;search&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;query_rewriting&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;QueryRewriting&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ResultObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;seekstorm-server-rest-api-integrated-symspellcomplete&quot;&gt;SeekStorm server REST API (integrated SymSpellComplete)&lt;/h3&gt;

&lt;p&gt;See &lt;a href=&quot;https://seekstorm.apidocumentation.com/reference&quot;&gt;REST API documentation&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;create-index-1&quot;&gt;Create Index&lt;/h4&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CreateIndexRequest&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;spelling_correction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SpellingCorrection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_completion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;QueryCompletion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;search-1&quot;&gt;Search&lt;/h4&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SearchRequestObject&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_rewriting&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;QueryRewriting&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;availability&quot;&gt;Availability&lt;/h2&gt;

&lt;p&gt;This has been quite a ride, to get a seemingly simple idea right. 
Now you are invited to test and use our first iteration of Query Auto-Completion (QAC) and Instant Search.  Advanced features, such as term-order-independent completions and completion of spelling-corrected partial queries, are scheduled for the next release.
Both the &lt;a href=&quot;https://github.com/SeekStorm/SeekStorm&quot;&gt;SeekStorm lexical search library and multi-tenancy server&lt;/a&gt; and the &lt;a href=&quot;https://github.com/wolfgarbe/symspell_complete_rs&quot;&gt;SymSpellComplete auto completion library&lt;/a&gt; are implemented in &lt;strong&gt;Rust&lt;/strong&gt; and released as &lt;strong&gt;open source&lt;/strong&gt; under the &lt;strong&gt;Apache 2.0 license&lt;/strong&gt;.&lt;/p&gt;
</description>
        <pubDate>Thu, 18 Dec 2025 00:00:00 +0000</pubDate>
        <link>https://seekstorm.com/blog/query-auto-completion-(QAC)/</link>
        <guid isPermaLink="true">https://seekstorm.com/blog/query-auto-completion-(QAC)/</guid>
        
        
        <category>search</category>
        
        <category>performance</category>
        
        <category>rust</category>
        
        <category>oss</category>
        
      </item>
    
      <item>
        <title>N-gram index for faster phrase search: latency vs. size</title>
        <description>&lt;h3 id=&quot;tldr&quot;&gt;TLDR;&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;N-Gram indexing improved &lt;strong&gt;phrase&lt;/strong&gt; mean query latency by a &lt;strong&gt;factor of 2.18 (118%)&lt;/strong&gt;,&lt;br /&gt;
p99.9 tail latency by a &lt;strong&gt;factor of 7.63 (663%)&lt;/strong&gt;,&lt;br /&gt;
and some phrase queries up to &lt;strong&gt;3 orders of magnitude&lt;/strong&gt;.&lt;/p&gt;

  &lt;p&gt;The SeekStorm sub-millisecond lexical search library &amp;amp; multi-tenancy server has been implemented in Rust,&lt;br /&gt;
and is open source licensed under the Apache License 2.0, and is available on &lt;a href=&quot;https://github.com/SeekStorm/SeekStorm&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;not-all-queries-and-data-are-made-equal&quot;&gt;Not all queries and data are made equal&lt;/h3&gt;

&lt;p&gt;If you strive for the best possible performance, there is no one-fits-all approach.&lt;/p&gt;

&lt;p&gt;Depending on the &lt;strong&gt;query type&lt;/strong&gt; (union, intersection, phrase) and on the &lt;strong&gt;term frequency&lt;/strong&gt; (posting list length) of your data,&lt;br /&gt;
many optimizations can be applied: WAND, MAXSCORE, roaring bitmaps, SIMD, galloping. Another interesting optimization is N-gram indexing.&lt;/p&gt;

&lt;h3 id=&quot;what-are-n-grams&quot;&gt;What are N-grams&lt;/h3&gt;

&lt;p&gt;In general, N-grams are contiguous sequences of n adjacent items (&lt;strong&gt;words&lt;/strong&gt;, &lt;strong&gt;characters&lt;/strong&gt;, or &lt;strong&gt;symbols&lt;/strong&gt;) extracted from a text.&lt;/p&gt;

&lt;p&gt;In SeekStorm, N-grams are contiguous sequences of two or three frequent and/or rare &lt;strong&gt;terms&lt;/strong&gt; as &lt;strong&gt;opposed to character sequences&lt;/strong&gt; (see below for a list of supported N-gram types), extracted from a document or query.&lt;/p&gt;

&lt;h3 id=&quot;what-are-frequent-terms&quot;&gt;What are frequent terms?&lt;/h3&gt;

&lt;p&gt;SeekStorm allows different N-gram types, each defined as a combination of two or three frequent and/or rare terms.
But what is the distinction between a frequent and a rare term? It is the number of times a term occurs within the index.
&lt;strong&gt;Rarer terms&lt;/strong&gt; have a &lt;strong&gt;higher discriminatory value&lt;/strong&gt;, which is also honoured by the BM25 formulae. 
&lt;strong&gt;Frequent terms&lt;/strong&gt;, on the other hand, have a &lt;strong&gt;lower discriminatory value&lt;/strong&gt;, but due to their frequent occurrence, they &lt;strong&gt;take up a lot of index space&lt;/strong&gt; and &lt;strong&gt;computing resources&lt;/strong&gt; during intersection.
Therefore, they are sometimes even excluded from indexing as &lt;strong&gt;stop words&lt;/strong&gt;. But this is no perfect solution, as there are valid queries, like &lt;em&gt;“The Who”&lt;/em&gt; or &lt;em&gt;“The Doors”&lt;/em&gt;, consisting of or containing frequent terms.
But where is the exact frontier, where a rare term becomes a frequent term and vice versa? There is no general definition.
It’s up to the user to define the frequent terms, and all other terms are treated as rare terms. In SeekStorm, this is done by providing a list of user-defined frequent terms during index creation.&lt;/p&gt;

&lt;p&gt;When defining frequent terms, you can simply take what would be considered &lt;strong&gt;stop words&lt;/strong&gt; in the language of the documents you are indexing.
The more terms you add to the frequent terms list, the more queries will benefit from the latency advantage of N-grams, at the cost of a higher index size.
The more frequent a term is, that is added to the frequent term list, the more pronounced is its latency benefit compared to its induced index size cost.&lt;/p&gt;

&lt;p&gt;Frequent terms are rare - i.e., there are only a few terms that frequently appear in almost every document.
We prefer combinations of frequent terms in n-grams for two reasons:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Frequent terms have long posting lists, and their conventional intersection would be expensive. By using N-grams instead, we can save the most, which otherwise would be the most expensive.&lt;/li&gt;
  &lt;li&gt;Because there are only a few frequent terms, the number of combinations with frequent terms and thus their additional index size cost is limited too. We optimize the &lt;strong&gt;fat head&lt;/strong&gt; instead of the &lt;strong&gt;long tail&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;how-about-automatic-detection-of-frequent-terms-during-indexing&quot;&gt;How about automatic detection of frequent terms during indexing?&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;language independent,&lt;/li&gt;
  &lt;li&gt;no pre-definition of frequent terms required&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Drawbacks&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;When indexing starts, we have no information about term frequency. We either need to index the first block without frequent terms and N-grams, or we need to reindex it once we have term frequencies collected.&lt;/li&gt;
  &lt;li&gt;Term frequencies might also change during indexing. Then we either need to reindex everything from scratch, or have different frequent terms per level, which would also require a different query rewriting to N-grams per block.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In SeekStorm, we forgo automatic detection of frequent terms, which makes both indexing and query more complicated and complex, in favor of a predefined set of frequent terms during index definition.&lt;/p&gt;

&lt;h3 id=&quot;how-does-n-gram-phrase-search-work&quot;&gt;How does N-gram phrase search work?&lt;/h3&gt;

&lt;p&gt;The intersection of frequent terms is challenging because their posting lists are very long, and the intersection takes a lot of time. Especially when very frequent terms (aka stopwords) are involved,
which occur in almost every document, that might significantly contribute to tail latencies.&lt;/p&gt;

&lt;p&gt;Examples of those queries are “The Who”, “Take That”, “Who is Who”, “Let it be”, “To be or not to be”, “End of Days”, “The The”, “What might have been”.&lt;/p&gt;

&lt;p&gt;One way to significantly reduce the query latency is by indexing N-grams in addition to single terms, essentially moving the computation of intersection and phrase matching from query time to indexing time.&lt;/p&gt;

&lt;p&gt;When we use N-gram indexing also for phrase search of rare terms besides frequent terms, or even for intersection (AND) by removing the condition that the N-gram terms have to be adjacent, this significantly
increases the index size.&lt;/p&gt;

&lt;p&gt;Such an approach has been used in the &lt;a href=&quot;https://en.wikipedia.org/wiki/Distributed_search_engine&quot;&gt;distributed web search engine FAROO&lt;/a&gt;. 
To keep the index size manageable, highly discriminative keys (HDK), noun-only indexing, aggressive stemming, and other keyword reduction techniques have been used.&lt;/p&gt;

&lt;p&gt;But when N-grams are restricted only to adjacent frequent terms, then the additional index cost in terms of space and time is negligible. 
On the other hand, those queries containing multiple adjacent frequent terms might be accelerated by 3 orders of magnitude,&lt;br /&gt;
because the posting list of the N-gram is much shorter than those of the original single terms. Also, for phrase queries of two or three frequent terms, no intersection and phrase matching is necessary anymore.&lt;br /&gt;
The phrase matching of consecutive N-grams (sequences containing frequent terms) and single terms (rare terms) is accelerated as well, as it becomes the intersection between a very short N-gram posting list and the other terms. This enables the use of additional accelerating techniques like galloping.&lt;/p&gt;

&lt;p&gt;While BM25 is not ideal for phrase search as it doesn’t honour term proximity, we might still want to use it for comparability so that the BM25 score and the topk results are identical whether we are using N-gram indexing (for performance) or not.&lt;/p&gt;

&lt;p&gt;To make N-gram indexing compatible with BM25 ranking, we have to implement additional measures. We store the posting_counts (DF) and the positions_count of the partial terms (TF) of the N-gram for BM25 calculation.
While we could have used the positions_count stored in the posting lists of single terms, it would be expensive to find the docid within the posting lists (docid/pointer list) of single terms via custom binary search. That would nullify the speed advantage of N-gram indexing. Therefore, we sacrifice some space to store the positions_counts of the single term together with the positions of the N-gram.&lt;/p&gt;

&lt;p&gt;N-gram indexing is orthogonal to other acceleration techniques mentioned above.&lt;/p&gt;

&lt;h3 id=&quot;traditional-phrase-search-vs-n-gram-phrase-search&quot;&gt;Traditional phrase search vs. N-gram phrase search&lt;/h3&gt;

&lt;p&gt;A traditional phrase search consists of two steps:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;First, we intersect two single-term posting lists (e.g., by merging and galloping).&lt;/li&gt;
  &lt;li&gt;Then, for each intersection match, we have to do a phrase check, by checking whether or not the term positions in the document are adjacent in the order of the phrase query terms. For long posting lists that can be expensive.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Both steps - intersection and phrase check - can be eliminated&lt;/strong&gt; if we already precalculate N-grams (bigram and trigram phrase matches) at index time. 
Then, at query time, for two- and three-term queries, the result list is directly available by accessing the appropriate n-gram posting lists.&lt;/p&gt;

&lt;p&gt;For phrase queries longer than three terms, the queries can be transformed to queries with fewer terms, consisting of n-grams.&lt;br /&gt;
After rewriting the query to N-grams, we have fewer terms, each with shorter posting lists, reducing the effort for intersection and the subsequent phrase check.&lt;/p&gt;

&lt;h3 id=&quot;n-grams-and-tokenizer&quot;&gt;N-grams and tokenizer&lt;/h3&gt;

&lt;p&gt;N-grams are generated in the tokenizer, both for indexing and search.&lt;/p&gt;

&lt;p&gt;For indexing all possible variants of overlapping N-grams are generated.
For searching a single variant of non-overlapping N-grams is chosen.&lt;/p&gt;

&lt;p&gt;We currently use a greedy algorithm for selecting the best N-grams for query rewriting.&lt;br /&gt;
We have also experimented with dynamic programming, and I adapted my &lt;a href=&quot;https://seekstorm.com/blog/fast-word-segmentation-noisy-text/&quot;&gt;Fast Word Segmentation algorithm&lt;/a&gt; (already ported from C# to Rust for the Chinese word segmentation in SeekStorm) for N-gram query rewriting using the Viterbi algorithm (Naive Bayes). 
But according to my benchmarks, the additional effort for Viterbi over Greedy was not always justified.&lt;/p&gt;

&lt;h3 id=&quot;n-grams-and-bm25&quot;&gt;N-grams and BM25&lt;/h3&gt;

&lt;p&gt;BM25 scores (&lt;code class=&quot;highlighter-rouge&quot;&gt;SimilarityType::Bm25f&lt;/code&gt;) are almost identical for both n-gram and single-term indexing. There are only small differences for phrase search resulting from 
normalization (32bit-&amp;gt;8bit-&amp;gt;32bit lossy logarithmic compression/decompression) that is used for posting_count_ngram1/2/3, but not for single term posting_counts.&lt;/p&gt;

&lt;p&gt;This is achieved as we store for every partial term of an n-gram its document frequency (DF), i.e. the number of documents a term occurs in. 
We also store for every partial term of an n-gram its term frequency (TF), i.e., the number of positions within a document.&lt;/p&gt;

&lt;p&gt;For the alternative BM25 proximity score (&lt;code class=&quot;highlighter-rouge&quot;&gt;SimilarityType::Bm25fProximity&lt;/code&gt;) we use DF and TF of the N-gram, as opposed to the DF and TF of its partial terms. 
This way, the proximity of terms within an N-gram is honored for scoring.&lt;br /&gt;
But then we can’t anymore score the posting list length and position count of the individual 2 or 3 ngram terms independently,&lt;br /&gt;
as we store only the posting list length and position count of the N-gram itself, but not its partial terms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example query: “tallest trees in the world”&lt;/strong&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; Top-10 DocID &lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; SingleTerm Bm25f &lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; Top-10 DocID &lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; faithful N-gram Bm25f &lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; Top-10 DocID &lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; N-gram Bm25fProximity &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2456001&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.940866&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2456001&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;17.131088&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;891973&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.5893530&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1615029&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.919497&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1615029&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;17.113970&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2456001&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.5521690&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;891973&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.165619&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;891973&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.351793&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1615029&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.5108185&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2094543&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.590414&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2094543&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.776010&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2094543&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.4961680&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1162534&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.225990&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1162534&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.413112&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1162534&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.2484310&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2676541&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.4227843&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2676541&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.5982113&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3494456&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.9255943&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3494456&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.3537903&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3494456&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.5184870&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3308553&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.3953430&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3308553&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.0942807&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3308553&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.2625637&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;958861&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.1408840&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;958861&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.9975886&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;958861&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.1672870&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2676541&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.5677156&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3513862&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.1011164&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3513862&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.2637115&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3513862&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.6718745&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;The small differences between SingleTerm Bm25f and faithful N-gram Bm25f are caused 
by lossy logarithmic compression/decompression of posting_count_ngram1/2/3, 
but the &lt;strong&gt;order of the top-10 DocID is mostly preserved&lt;/strong&gt;.&lt;/p&gt;

&lt;h3 id=&quot;seekstorm-n-gram-indexing&quot;&gt;SeekStorm N-gram indexing&lt;/h3&gt;

&lt;p&gt;SeekStorm had &lt;strong&gt;bigram indexing&lt;/strong&gt; of two adjacent frequent terms from the very beginning.&lt;br /&gt;
This allows for very fast phrase search of phrase mode of frequent terms, e.g., “The Who” (the rock band).&lt;br /&gt;
And bi-grams of frequent terms deliver ‘the best bang for the buck’ in terms of latency improvement vs. index size increase trade-off, as we will see below.&lt;/p&gt;

&lt;p&gt;But starting with &lt;strong&gt;SeekStorm v0.13.0&lt;/strong&gt;, we go a step further with a more &lt;strong&gt;generalized approach to n-gram indexing&lt;/strong&gt;.&lt;br /&gt;
Instead of only indexing two frequent terms as a bigram in addition to the single term, we allow fo indexing the following term combinations as N-grams:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;SingleTerm&lt;/li&gt;
  &lt;li&gt;NgramFF  : frequent frequent&lt;/li&gt;
  &lt;li&gt;NgramFR  : frequent rare&lt;/li&gt;
  &lt;li&gt;NgramRF  : rare frequent&lt;/li&gt;
  &lt;li&gt;NgramFFF : frequent frequent frequent&lt;/li&gt;
  &lt;li&gt;NgramRFF : rare frequent frequent&lt;/li&gt;
  &lt;li&gt;NgramFFR : frequent frequent rare&lt;/li&gt;
  &lt;li&gt;NgramFRF : frequent rare frequent&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;During index creation, the user can define &lt;strong&gt;any combination&lt;/strong&gt; of the above N-gram types to be supported during indexing and search. SingleTerm indexing is &lt;strong&gt;always&lt;/strong&gt; enabled.&lt;/p&gt;

&lt;p&gt;N-gram indexing &lt;strong&gt;reduces the latency&lt;/strong&gt;, but &lt;strong&gt;only for phrase search&lt;/strong&gt;. Some phrase queries are &lt;strong&gt;3 orders of magnitude&lt;/strong&gt; faster.&lt;br /&gt;
But N-gram indexing comes at the cost of &lt;strong&gt;increasing&lt;/strong&gt; both &lt;strong&gt;index size&lt;/strong&gt; and &lt;strong&gt;indexing time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;While it’s not easy to go faster if you are already using the fastest processor, it is easy to go faster with N-gram indexing by sacrificing some storage space, as you usually haven’t maxed out disk capacity yet.&lt;br /&gt;
Also, upgrading storage is usually much more affordable than upgrading to a faster processor.&lt;/p&gt;

&lt;p&gt;With N-gram indexing, SeekStorm follows the successful &lt;a href=&quot;https://github.com/wolfgarbe/SymSpell&quot;&gt;SymSpell&lt;/a&gt; pattern: trade index space and indexing time for query speed - as an option.&lt;/p&gt;

&lt;p&gt;We provide benchmarks for latency, indexing speed, and index size to allow the user to make an informed decision about when to use N-gram indexing.&lt;/p&gt;

&lt;p&gt;Every use case is different, with different data and different trade-off preferences. With SeekStorm v0.13.0, you now have a choice.&lt;/p&gt;

&lt;h3 id=&quot;how-about-rewriting-and-queries-to-phrase-queries&quot;&gt;How about rewriting AND queries to Phrase queries?&lt;/h3&gt;

&lt;p&gt;Unfortunately, the use of explicit phrase queries by typing “” is not internalized by the average user, 
even if his intent was obviously to perform a phrase query.&lt;/p&gt;

&lt;p&gt;How about rewriting AND queries to Phrase queries? This would allow AND queries to profit from the faster speed of N-gram phrase queries.&lt;br /&gt;
But it comes at a cost. If the AND query was not intended as a phrase query, we might get insufficient results with bad recall.&lt;/p&gt;

&lt;p&gt;There are some heuristics. If the user is searching for two frequent terms or a rare and a frequent term, it is most likely intended as a phrase query, 
just because a frequent term outside a phrase doesn’t add much discriminatory value to the query.&lt;/p&gt;

&lt;p&gt;Another way is to start with rewriting the query as a phrase query. This will not only speed up the query but also lead to more relevant results.&lt;br /&gt;
In the case that not enough results are found, we could fall back to a normal AND/OR query.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Traditional Phrase search is always slower than AND search, because Phrase search = AND search + additional Phrase check.&lt;br /&gt;
But for N-gram Phrase search, usually the opposite is true. That’s why rewriting AND queries to N-gram Phrase queries is worth considering.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;could-we-use-the-n-gram-principle-for-intersection-and-search&quot;&gt;Could we use the N-gram principle for intersection (AND) search?&lt;/h3&gt;

&lt;p&gt;Not exactly. Because n-grams are consecutive occurrences of terms in a document, they are suitable for phrase search only.
In AND search, the terms of a query might occur everywhere within a document, and thus wouldn’t be covered by N-grams.&lt;/p&gt;

&lt;p&gt;But there is something slightly similar: Keyword combination indexing. We could derive all keyword combinations that occur within a document and index those combinations in addition to the single terms and N-grams.
This would be essentially a precalculation of AND search at indexing time, and offer the same speed benefits to AND search that N-Gram indexing offers for Phrase search.&lt;/p&gt;

&lt;p&gt;There is only one problem: The associated cost of naive keyword combination indexing in terms of index size and indexing time is unbearable. 
The number of combinations without repetition is C(n, k) = ∑ᵢ₌₁..ₖ  n! / (i!(n-i)!),
where n is the number of unique terms in a document and k is the keyword combination length, 
i.e., the maximum number of terms in an AND query we want to support = the maximum number of terms in a keyword combination we need to index.&lt;/p&gt;

&lt;p&gt;E.g., a document with 200 unique terms and a maximum query length of 5 ≈ 2,600,000,000 combinations we need to index!&lt;/p&gt;

&lt;p&gt;Luckily, there are several compression methods to significantly reduce the number of keyword combinations per document:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Stopword removal&lt;/li&gt;
  &lt;li&gt;Stemming&lt;/li&gt;
  &lt;li&gt;Highly discriminative keys (HDK)&lt;/li&gt;
  &lt;li&gt;Indexing title only&lt;/li&gt;
  &lt;li&gt;Indexing highly relevant documents only&lt;/li&gt;
  &lt;li&gt;verb removal - indexing nouns only&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HDK (high discriminative key) is an interesting concept, where keyword combinations are only formed from frequent terms and term combinations, until the resulting term combination becomes &lt;strong&gt;intrinsically rare&lt;/strong&gt;.&lt;br /&gt;
In a second step, within those intrinsically rare posting lists, a full check of all query terms is done within bloom filters of terms associated with every document in the intrinsically rare posting list.&lt;br /&gt;
For details, see &lt;a href=&quot;https://www.researchgate.net/publication/4250903_Scalable_Peer-to-Peer_Web_Retrieval_with_Highly_Discriminative_Keys&quot;&gt;Scalable Peer-to-Peer Web_Retrieval with Highly Discriminative Keys&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Some of the above methods are reducing recall, but increasing relevancy. This could be useful in a two-tier approach, where we first try to find results with fast keyword combination search, 
and only if that fails, we would fall back to slow conventional intersection.&lt;/p&gt;

&lt;p&gt;I have used keyword combination indexing successfully 20 years ago when implementing the FAROO decentralized peer-to-peer web search engine.
We used a DHT (distributed hash table) to store the posting lists at different peers (with a 20-fold redundancy to fight churn). 
As it was infeasible to transfer long posting lists between peers and users in real-time at search time, we had to find a solution for intersection without posting list transfer.
That’s why we back then chose keyword combination indexing.&lt;/p&gt;

&lt;h3 id=&quot;benchmarks&quot;&gt;Benchmarks&lt;/h3&gt;

&lt;p&gt;Benchmark results highly depend on the selected data and query set, as well as on the hardware and software environment.&lt;/p&gt;

&lt;p&gt;We are using the &lt;strong&gt;English Wikipedia&lt;/strong&gt; data and queries derived from the &lt;strong&gt;AOL query dataset&lt;/strong&gt;, both from Tantivy’s &lt;a href=&quot;https://github.com/quickwit-oss/search-benchmark-game/&quot;&gt;search-benchmark-game&lt;/a&gt;. 
The benchmark has been executed in single-thread, single-shard mode without caching.&lt;/p&gt;

&lt;p&gt;The results were generated using the following benchmark environment:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;ThinkPad P1 Gen 6&lt;/li&gt;
  &lt;li&gt;Processor Intel(R) Core(TM) i7-13700H&lt;/li&gt;
  &lt;li&gt;SK hynix 2TB SSD PCIe 4.0 NVMe M.2&lt;/li&gt;
  &lt;li&gt;Ubuntu 24.04 LTS&lt;/li&gt;
  &lt;li&gt;Rust 1.88&lt;/li&gt;
  &lt;li&gt;OpenJDK 17&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;comparison-of-different-n-gram-type-combinations-in-terms-of-phrase-query-latency&quot;&gt;Comparison of different N-gram type combinations in terms of &lt;strong&gt;phrase&lt;/strong&gt; query latency&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\ngram_latency.png&quot; alt=&quot;phrase search tail latencies&quot; /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Library&lt;/th&gt;
      &lt;th&gt;N-gram type&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;mean (µs)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;factor&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;p50 (µs)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;factor&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;p95 (µs)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;factor&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;p99 (µs)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;factor&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;p99.9 (µs)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;factor&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Single Terms&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1,090&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.00&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;320&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.00&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;2,990&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.00&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;16,910&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.00&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;60,490&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.00&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;890&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.22&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;320&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3,180&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.94&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10,230&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.65&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;26,070&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.32&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Frequent Bigrams/Frequent Trigrams&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;880&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.24&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;320&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.00&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;2,850&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.05&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;8,950&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.89&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;24,430&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;2.48&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;820&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.33&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;310&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.03&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2,890&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.03&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8,440&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.00&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;24,840&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.44&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;510&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.14&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;260&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.23&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1,050&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.84&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3,800&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.45&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8,050&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.51&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Mixed Bigrams/Frequent Trigrams&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;500&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;2.18&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;260&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.23&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1,890&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.58&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;3,820&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;4.43&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;7,930&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;7.63&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;510&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.14&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;270&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.19&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1,790&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.67&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3,850&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.39&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8,180&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.39&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7&lt;/strong&gt; (Frequent Bigrams) vs. &lt;strong&gt;51&lt;/strong&gt; (Mixed Bigrams + Mixed Trigrams) of &lt;strong&gt;903&lt;/strong&gt; queries in the benchmark are benefiting from N-gram indexing. 
Those are usually the most challenging ones, causing high tail latencies.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;N-gram indexing can help to drastically reduce tail latencies.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For more information on tail latencies see our blog post &lt;a href=&quot;https://seekstorm.com/blog/tail-latencies-and-percentiles/&quot;&gt;Tail latencies and percentiles&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;the-cost-of-n-grams-index-size-and-indexing-time&quot;&gt;The cost of N-grams: index size and indexing time&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Library&lt;/th&gt;
      &lt;th&gt;N-gram type&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Index size (byte)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; factor&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; Indexing time (s)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; factor&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Single Terms&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;3.880.714.411&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.00&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;558&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.00&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.476.185.397&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.15&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;605&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.08&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Frequent Bigrams/Frequent Trigrams&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;4.613.052.374&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.19&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;636&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1.14&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9.680.952.871&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.49&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2203&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.95&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;11.314.218.483&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.92&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2138&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3.83&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Mixed Bigrams/Frequent Trigrams&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;11.531.297.587&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;2.97&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;2204&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;3.95&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.599.113.374&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4.28&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4164&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.46&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h4 id=&quot;some-challenging-phrase-queries-containing-frequent-terms&quot;&gt;Some challenging phrase queries containing frequent terms:&lt;/h4&gt;

&lt;h3 id=&quot;the-who&quot;&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/The_Who&quot;&gt;“the who”&lt;/a&gt;&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Library&lt;/th&gt;
      &lt;th&gt;N-gram type&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;latency (µs)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; factor&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; N-gram query rewriting&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Single Terms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;151,850 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;the who&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Frequent Bigrams&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;120 &lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;1,265.00&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;the_who&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams/Frequent Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;140 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.084.64&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;the_who&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;130 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1,178.08&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;the_who&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;90 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1,687.00&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;the_who&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Frequent Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;80 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1,898.12&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;the_who&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;140 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.084.64&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;the_who&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3 id=&quot;the-doors&quot;&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/The_Doors&quot;&gt;“the doors”&lt;/a&gt;&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Library&lt;/th&gt;
      &lt;th&gt;N-gram type&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;latency (µs)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; factor&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; N-gram query rewriting&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Single Terms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8,160 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;the doors&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9,500 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.86&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;the doors&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams/Frequent Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7,480 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.09&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;the doors&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8,890 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.92&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;the doors&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;130 &lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;62.77&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;the_doors&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Frequent Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;140 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;58.29&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;the_doors&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;140 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;58.29&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;the_doors&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3 id=&quot;who-is-who&quot;&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Who%27s_Who&quot;&gt;“who is who”&lt;/a&gt;&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Library&lt;/th&gt;
      &lt;th&gt;N-gram type&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;latency (µs)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; factor&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; N-gram query rewriting&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Single Terms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;65,220 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;who is who&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8,280 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.88&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;who_is&lt;/span&gt; who&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Frequent Bigrams/Frequent Trigrams&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;70 &lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;931.71&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color:#00AB6B&quot;&gt;who_is_who&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;80 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;815.25&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#00AB6B&quot;&gt;who_is_who&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9,940 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.56&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;who_is&lt;/span&gt; who&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Frequent Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;80 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;815.25&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#00AB6B&quot;&gt;who_is_who&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;60 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1,087.00&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#00AB6B&quot;&gt;who_is_who&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3 id=&quot;to-be-or-not-to-be&quot;&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/To_be,_or_not_to_be&quot;&gt;“to be or not to be”&lt;/a&gt;&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Library&lt;/th&gt;
      &lt;th&gt;N-gram type&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;latency (µs)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; factor&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; N-gram query rewriting&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Single Terms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;60,880 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;to be or not to be&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2,190 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;27.80&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;to_be&lt;/span&gt; &lt;span style=&quot;color:#006BAB&quot;&gt;or_not&lt;/span&gt; &lt;span style=&quot;color:#006BAB&quot;&gt;to_be&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Frequent Bigrams/Frequent Trigrams&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;220 &lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;276.73&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color:#00AB6B&quot;&gt;to_be_or&lt;/span&gt; &lt;span style=&quot;color:#00AB6B&quot;&gt;not_to_be&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;240 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;253.67&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#00AB6B&quot;&gt;to_be_or&lt;/span&gt; &lt;span style=&quot;color:#00AB6B&quot;&gt;not_to_be&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4,080 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;14.92&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;to_be&lt;/span&gt; &lt;span style=&quot;color:#006BAB&quot;&gt;or_not&lt;/span&gt; &lt;span style=&quot;color:#006BAB&quot;&gt;to_be&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Frequent Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;250 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;243.52&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#00AB6B&quot;&gt;to_be_or&lt;/span&gt; &lt;span style=&quot;color:#00AB6B&quot;&gt;not_to_be&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;170 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;358.12&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#00AB6B&quot;&gt;to_be_or&lt;/span&gt; &lt;span style=&quot;color:#00AB6B&quot;&gt;not_to_be&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3 id=&quot;pump-it-up&quot;&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Pump_It_Up!&quot;&gt;“pump it up”&lt;/a&gt;&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Library&lt;/th&gt;
      &lt;th&gt;N-gram type&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;latency (µs)&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; factor&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; N-gram query rewriting&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Single Terms&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2,220 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;pump it up&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;SeekStorm 0.13.0&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;Frequent Bigrams&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;200 &lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;11.10&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;pump &lt;span style=&quot;color:#006BAB&quot;&gt;it_up&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams/Frequent Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;210 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;10.57&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;pump &lt;span style=&quot;color:#006BAB&quot;&gt;it_up&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Frequent Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;50 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;44.40&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#00AB6B&quot;&gt;pump_it_up&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;310 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.16&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;pump_it&lt;/span&gt; up&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Frequent Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;310 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7.16&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#006BAB&quot;&gt;pump_it&lt;/span&gt; up&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;SeekStorm 0.13.0&lt;/td&gt;
      &lt;td&gt;Mixed Bigrams/Mixed Trigrams&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;70 &lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31.71&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;span style=&quot;color:#00AB6B&quot;&gt;pump_it_up&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3 id=&quot;recommended-n-gram-combinations&quot;&gt;Recommended N-gram combinations&lt;/h3&gt;

&lt;p&gt;Not all that is possible makes sense for everybody, with every workload. 
Here we propose a sensible trade-off between query performance improvement and index size cost, while preventing diminishing returns.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Looking at the benchmark results above and the associated index size cost, at first glance, it looks unreasonable to accept a 3x higher index size.&lt;br /&gt;
But in order to reduce tail latency by a factor of 8, it would be much easier and less expensive to increase the disk capacity by a factor of 3, than to have 8x faster processors or increase the node number by a factor of 8.&lt;br /&gt;
Furthermore, for medium-sized indices (&amp;lt;100 GB), index size is usually no concern at all, but (tail) latency is.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When &lt;strong&gt;minimum index size&lt;/strong&gt; is more important than phrase query latency, we recommend &lt;strong&gt;Single Terms&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nn&quot;&gt;NgramSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SingleTerm&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;u8&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For a &lt;strong&gt;good balance of latency and index size&lt;/strong&gt; cost, we recommend &lt;strong&gt;Single Terms + Frequent Bigrams + Frequent Trigrams&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nn&quot;&gt;NgramSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SingleTerm&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;u8&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;NgramSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NgramFF&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;u8&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;NgramSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NgramFFF&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When &lt;strong&gt;minimal phrase query latency&lt;/strong&gt; is more important than low index size, we recommend &lt;strong&gt;Single Terms + Mixed Bigrams + Frequent Trigrams&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nn&quot;&gt;NgramSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SingleTerm&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;u8&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;NgramSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NgramFF&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;u8&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;NgramSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NgramFR&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;u8&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;NgramSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NgramRF&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;NgramSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NgramFFF&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;summary&quot;&gt;Summary&lt;/h3&gt;

&lt;p&gt;N-Gram indexing improved latency for &lt;strong&gt;some&lt;/strong&gt; &lt;strong&gt;phrase&lt;/strong&gt; queries, at the cost of higher index size and indexing time.
The improvements for tail latencies are even higher than for mean query latency.&lt;/p&gt;

&lt;p&gt;Using N-gram indexing, the following &lt;strong&gt;phrase search&lt;/strong&gt; improvements have been measured:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;mean query latency by &lt;strong&gt;factor 2.18 (118%)&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;p99.9 tail latency by &lt;strong&gt;factor 7.63 (663%)&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Some queries are up to &lt;strong&gt;3 orders of magnitude&lt;/strong&gt; faster: e.g., “the who” by a factor of 1687 (168,600%)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To implement N-gram indexing for faster phrase search, &lt;strong&gt;30% of 25K LoC&lt;/strong&gt; of the SeekStorm codebase have been added, removed, or changed.&lt;/p&gt;

&lt;h3 id=&quot;further-improvements&quot;&gt;Further improvements&lt;/h3&gt;

&lt;p&gt;So far, we have indexed the N-grams that occurred in the documents, independent of the likelihood that they will appear in queries. 
With a probabilistic approach (i.e., via query log file analysis), we can judge how likely certain N-grams are to appear in queries, and we can abstain from indexing less likely N-grams.&lt;/p&gt;

&lt;p&gt;The more likely N-grams can be stored in a Bloom filter, which is consulted during indexing and search to determine whether or not to combine terms into N-grams.
This will significantly reduce the index size and indexing time overhead of N-gram indexing, while mostly maintaining its query latency benefits.&lt;/p&gt;

&lt;p&gt;The achieved space savings can be used to increase the number of terms deemed to be frequent, and thus further improve (tail) latencies for more phrase queries.&lt;/p&gt;

&lt;p&gt;Another improvement are N-grams with negative offsets: instead of rewriting “who is who” to “&lt;span style=&quot;color:#006BAB&quot;&gt;who_is&lt;/span&gt; who” we could rewrite it to “&lt;span style=&quot;color:#006BAB&quot;&gt;who_is is_who&lt;/span&gt;”,
where the second bigram would have a offset of -1 for phrase check. This would lead to a shorter posting list for the second bigram ‘is_who’, compared to the posting list of a single term ‘who’, reducing latency.&lt;/p&gt;

&lt;h3 id=&quot;source-code&quot;&gt;Source code&lt;/h3&gt;

&lt;p&gt;The SeekStorm sub-millisecond lexical search library &amp;amp; multi-tenancy server has been implemented in Rust,&lt;br /&gt;
is open source licensed under the Apache License 2.0, and is available on &lt;a href=&quot;https://github.com/SeekStorm/SeekStorm&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Fri, 08 Aug 2025 00:00:00 +0000</pubDate>
        <link>https://seekstorm.com/blog/n-gram-indexing-for-faster-phrase-search/</link>
        <guid isPermaLink="true">https://seekstorm.com/blog/n-gram-indexing-for-faster-phrase-search/</guid>
        
        
        <category>performance</category>
        
      </item>
    
      <item>
        <title>The mystery of an 85% performance drop, lost in translation between CPU and OS.</title>
        <description>&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@omilaev?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash&quot;&gt;Igor Omilaev&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;TLDR : &lt;strong&gt;85% performance drop&lt;/strong&gt; caused by a &lt;strong&gt;faulty Windows 11 24H2 software update&lt;/strong&gt;,&lt;br /&gt;
that changed the &lt;strong&gt;task scheduler&lt;/strong&gt; behavior into &lt;strong&gt;under-utilizing the P-Cores&lt;/strong&gt; over E-cores of &lt;strong&gt;Intel hybrid CPUs&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;stakeholders-and-their-interplay-hardware-os-compiler-code&quot;&gt;Stakeholders and their interplay: Hardware, OS, Compiler, Code&lt;/h3&gt;

&lt;p&gt;This story is about performance, here specifically about MS Windows 11 and Intel hybrid CPUs, or rather their non-optimal interplay.&lt;br /&gt;
It is a story about the little surprises of all the actors secretly interfering with your work in ways that you might not always be aware of.&lt;/p&gt;

&lt;p&gt;I know, I might be an outlier, developing on a Windows laptop, knowing that the software will ultimately run on a Linux server in most cases.&lt;br /&gt;
But that way, cross-platform development is internalized, not only an afterthought.&lt;/p&gt;

&lt;p&gt;And I think the tale might be interesting even for Linux purists who never leave their beloved command line.&lt;br /&gt;
When developing high-performance software we know that architecture, data structures, algorithms, and hardware (processor, RAM, SSD) will determine the outcome.&lt;/p&gt;

&lt;p&gt;Sometimes the operating system influences the performance as well, depending on drivers, the file system implementation, memory mapping, or OS-specific features like io_uring or IoRing.&lt;/p&gt;

&lt;p&gt;Sometimes, CPU vendors add promising features, like the &lt;a href=&quot;https://en.wikipedia.org/wiki/AVX-512&quot;&gt;AVX512 VP2INTERSECT&lt;/a&gt;,&lt;br /&gt;
that made a brief appearance on Tiger Lake only to disappear from Intel altogether afterward.&lt;br /&gt;
So we can’t rely that what we have today, will be usable tomorrow, by us and our users.&lt;/p&gt;

&lt;p&gt;Between our algorithms and the hardware there is also a compiler and possibly an .Net framework or Java virtual machine,&lt;br /&gt;
that might influence the efficiency of the produced code, and even might prohibit us e.g. from using &lt;a href=&quot;https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_cmpistrm&amp;amp;ig_expand=1044&quot;&gt;_mm_cmpistrm&lt;/a&gt;,&lt;br /&gt;
a SIMD hardware acceleration feature present in our CPU that is very useful for intersection, &lt;a href=&quot;https://github.com/dotnet/runtime/discussions/63332&quot;&gt;but not supported by some programming languages&lt;/a&gt; for years.&lt;br /&gt;
The latter was the final straw that made me switch from C# to Rust.&lt;/p&gt;

&lt;p&gt;Those are the things we are aware of. But then there are things, that might catch us by unpleasant surprise.&lt;/p&gt;

&lt;p&gt;Windows 11 offers 3 power modes:  best power efficiency, balanced, and best performance. Choosing the balance of performance/noise/energy consumption - your call.&lt;br /&gt;
For developing and testing I always have &lt;strong&gt;best performance&lt;/strong&gt; switched on.&lt;br /&gt;
But yet, suddenly something was off…&lt;/p&gt;

&lt;h3 id=&quot;the-problem&quot;&gt;The problem&lt;/h3&gt;

&lt;p&gt;During benchmarking, I suddenly experienced an 85% performance drop in index time, query latency, and throughput.&lt;/p&gt;

&lt;p&gt;At first, I thought I had introduced some problem in the code, but I later realized that all the old SeekStorm versions as well as other open-source search libraries that were fine before,&lt;br /&gt;
suddenly exhibited the same performance degradation on my Windows 11 laptop with &lt;strong&gt;Intel Core i7 13700H&lt;/strong&gt; (14 cores, divided in 6 performance-cores 6 and 8 efficiency-cores).&lt;/p&gt;

&lt;p&gt;I benchmarked the code on another laptop with &lt;strong&gt;AMD Ryzen 7 6800H&lt;/strong&gt; (8 cores), and sure enough, everything was fine.&lt;/p&gt;

&lt;p&gt;I wrote a simple benchmark in Rust, to make sure the processor (or rather the OS as we will see later) is the culprit and not the SSD.&lt;br /&gt;
The simple benchmark just tries to saturate all processor cores with concurrent, multi-threaded dummy calculations. For the full benchmark code see below.&lt;/p&gt;

&lt;p&gt;On the Intel Core i7 13700H we can see on the task manager screenshots that at first all cores are 100% utilized,&lt;br /&gt;
but after a short time, the utilization drops to 25%, with only 8 &lt;strong&gt;efficiency cores&lt;/strong&gt; busy, and even those cores are not fully saturated, while all &lt;strong&gt;performance cores&lt;/strong&gt; are idle.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Screenshot 1: ThinkPad P1 Gen 6 / Intel Core i7 13700H (Performance degradation)&lt;br /&gt;
Elapsed time: &lt;strong&gt;106.714 s&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\ThinkPad_P1_Gen6.png&quot; width=&quot;800&quot; alt=&quot;Intel Core i7 13700H&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;While on the AMD Ryzen 7 6800H all cores are properly saturated.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Screenshot 2: Lenovo Legion 5 Pro / AMD Ryzen 7 6800H (Performance unchanged)&lt;br /&gt;
Elapsed time: &lt;strong&gt;29.737 s&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\Legion_5_pro.png&quot; width=&quot;800&quot; alt=&quot;AMD Ryzen 7 6800H&quot; /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;I didn’t tinker with the hardware, nor did I install or update any software recently. I checked the Windows update log, but there also wasn’t something suspicious.&lt;br /&gt;
I even cleaned the dust from the fans and did all BIOS and OS updates, but the issue remained.&lt;/p&gt;

&lt;h3 id=&quot;finding-the-culprit&quot;&gt;Finding the culprit&lt;/h3&gt;

&lt;p&gt;So my first working thesis was that my mobile Intel processor might exhibit the same &lt;a href=&quot;https://www.reddit.com/r/intel/comments/1egthzw/megathread_for_intel_core_13th_14th_gen_cpu/&quot;&gt;performance problems that were previously described mainly for the Desktop Version of the Intel Core 13th &amp;amp; 14th Gen CPU&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I was almost ready to give in and buy a new laptop, spending between 3000…4000 Euro. And going through the annoyance of setting up all the software again.&lt;br /&gt;
I was researching the latest advancements in processor technology and finally settled between an Intel Core Ultra9 275hx or an AMD 9955hx3d.&lt;br /&gt;
The AMD was not yet available and I was leaning toward the Intel despite its lack of AVX512 VP2INTERSECT.&lt;/p&gt;

&lt;p&gt;Before making the final decision I read some comparison reviews. It hit me when I suddenly spotted the following comment “Avoiding the P core vs E core scheduling issues on this 13900HX…”.&lt;br /&gt;
Could those “P core vs E core scheduling issues” be the root cause of my 85% performance drop?&lt;/p&gt;

&lt;p&gt;Software usually doesn’t use the highest thread priority, to give concurrently running programs space and ensure an overall responsive system.&lt;br /&gt;
&lt;a href=&quot;https://aloiskraus.wordpress.com/2024/02/08/hybrid-cpu-performance-on-windows-10-and-11/&quot;&gt;That approach has worked for a long time, but it has some unintended side effects that are not well understood when hybrid CPUs enter the game.&lt;/a&gt;&lt;br /&gt;
After more research, I found that Windows 11 24H2 and the following updates silently introduced a &lt;a href=&quot;https://techcommunity.microsoft.com/discussions/windowsinsiderprogram/w11-24h2-task-scheduler-and-underutilization-of-p-cores-over-e-cores-in-critical/4261070&quot;&gt;problem with the Task scheduler and underutilization of P-Cores over E-cores&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;the-fix&quot;&gt;The fix&lt;/h3&gt;

&lt;p&gt;How to fix it? The surprisingly easy way is to start your program &lt;strong&gt;as an administrator&lt;/strong&gt; or with &lt;a href=&quot;https://learn.microsoft.com/de-de/windows/sudo/&quot;&gt;Sudo for Windows&lt;/a&gt;.&lt;br /&gt;
Alternatively, you can set the thread priority to high &lt;a href=&quot;https://www.wikihow.com/Make-a-Program-Start-at-High-Priority-(Windows)&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;start &quot;benchmark&quot; /high &quot;benchmark.exe&quot;&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;An of course, there is a Rust fix for that too - that doesn’t require the users intervention.&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;//use the winapi crate with the winbase featere activated:&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;//winapi = { version =&quot;0.3.9&quot;,  features = [&quot;winbase&quot;]}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Instant&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;num_format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Locale&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ToFormattedString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Semaphore&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;winapi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;um&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;processthreadsapi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetCurrentProcess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SetPriorityClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;winbase&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ABOVE_NORMAL_PRIORITY_CLASS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;#[tokio&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;main]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Send&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Sync&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;// Fixes a 85% performance drop caused by a faulty Windows 11 24H2 software update,  &lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;// that changed the task scheduler behavior into under-utilizing the P-Cores over E-cores of Intel hybrid CPUs.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;// This is a workaround until Microsoft fixes the issue in a future update.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setpriorityclass&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;#[cfg(target_os&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;windows&quot;&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;)]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;process&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;GetCurrentProcess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;SetPriorityClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ABOVE_NORMAL_PRIORITY_CLASS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Et Voila - the full performance is back, 4000 Euro saved and I can cure my headache.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Screenshot 3: ThinkPad P1 Gen 6 / Intel Core i7 13700H (Full performance after fix)&lt;br /&gt;
Elapsed time: &lt;strong&gt;16.520 s&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;..\assets\images\ThinkPad_P1_Gen6_fixed.png&quot; width=&quot;800&quot; alt=&quot;Intel Core i7 13700H&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Unbelievably, my capable laptop would have almost landed at the scrapyard, for no other reasons than a careless software update.&lt;br /&gt;
One would think that the two giant companies involved in this disaster would have more throughout testing in place before jeopardizing the equipment of their customers.&lt;br /&gt;
They brag when they achieve a 10% performance increase between processor generations. But here, 85% drop - and silence!&lt;br /&gt;
I guess many users, who aren’t as performance-obsessed as I am, are not fully aware of to what extent their computers became lame and half-dead.&lt;br /&gt;
They will feel that their computer has become slower and more laggy, but many are used to that certain operating systems become slower over time.&lt;br /&gt;
Even worse, user trying SeekStorm on Windows for a quick evaluation would blame it on our software.&lt;/p&gt;

&lt;p&gt;Let’s hope that the Windows issue gets finally fixed, and things get back to normal without the need for the &lt;strong&gt;admin rights hack&lt;/strong&gt; or &lt;strong&gt;fiddling with priorities&lt;/strong&gt;.&lt;br /&gt;
Priorities are for prioritizing between multiple applications, but wilfully forcing most of the processor cores into an idle or under-utilized state,&lt;br /&gt;
despite that there is a multi-threaded, performance-critical application running that is able to fully saturate all processor cores if only the OS would let it?&lt;br /&gt;
That’s not a genius move, especially if the computer is &lt;strong&gt;connected to the main power&lt;/strong&gt; and the &lt;strong&gt;best performance is selected&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But now that this is out of the way, let’s get back to building the future of search 🙂.&lt;/p&gt;

&lt;h3 id=&quot;benchmark-program-rust&quot;&gt;Benchmark program (Rust)&lt;/h3&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Instant&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;num_format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Locale&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ToFormattedString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Semaphore&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_000&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;//50_000_000&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;f64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.tan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;#[tokio&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;main]&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Send&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Sync&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;thread_number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;permits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Semaphore&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;thread_number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start_time&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Instant&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_000_000&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;permit_thread&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;permits&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.clone&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.acquire_owned&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.await&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;spawn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;move&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.await&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;permit_thread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_000&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;docs {}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.to_formatted_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Locale&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;en&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;//wait for all threads to finish&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;permit_vec&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_i&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;thread_number&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;permit_vec&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.push&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;permits&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.acquire&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.await&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elapsed_time&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start_time&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.elapsed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.as_nanos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Elapsed time: {:.3} s&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elapsed_time&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;f64&lt;/span&gt; / &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_000_000_000&lt;/span&gt;.&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Press Enter to exit...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;stdin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.read_line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(())&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Thu, 01 May 2025 00:00:00 +0000</pubDate>
        <link>https://seekstorm.com/blog/80-percent-performance-drop/</link>
        <guid isPermaLink="true">https://seekstorm.com/blog/80-percent-performance-drop/</guid>
        
        
        <category>performance</category>
        
      </item>
    
      <item>
        <title>SeekStorm sharded index architecture - using a multi-core processor like a miniature data center</title>
        <description>&lt;p&gt;Photo by &lt;a href=&quot;https://unsplash.com/@jcw?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash&quot;&gt;Jim Witkowski&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;tldr--46x-faster-indexing--3x-faster-search&quot;&gt;TLDR : 4..6x faster indexing &amp;amp; 3x faster search&lt;/h2&gt;

&lt;p&gt;Never settle! SeekStorm already excels at query latency and throughput. But there is always room for improvement.&lt;br /&gt;
Time to tackle indexing speed and quadruple down on query latency.&lt;/p&gt;

&lt;h2 id=&quot;sharding&quot;&gt;Sharding&lt;/h2&gt;

&lt;p&gt;A &lt;a href=&quot;https://en.wikipedia.org/wiki/Shard_(database_architecture)&quot;&gt;shard&lt;/a&gt; is a horizontal partition of data in a database or search engine.&lt;br /&gt;
Usually, each shard is held on a separate database server instance, to both spread indexing and query load and split a large index across multiple servers.&lt;/p&gt;

&lt;p&gt;Distributing an index over multiple shards and servers allows scaling &lt;strong&gt;index size&lt;/strong&gt;, &lt;strong&gt;indexing speed&lt;/strong&gt;, &lt;strong&gt;query load&lt;/strong&gt;, and &lt;strong&gt;query latency&lt;/strong&gt; beyond the capacity of a single server.&lt;/p&gt;

&lt;p&gt;Benefits&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;faster indexing&lt;/li&gt;
  &lt;li&gt;faster searching&lt;/li&gt;
  &lt;li&gt;higher throughput&lt;/li&gt;
  &lt;li&gt;larger index size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This principle has been used e.g. by Google* &lt;a href=&quot;https://static.googleusercontent.com/media/research.google.com/en//archive/googlecluster-ieee.pdf&quot;&gt;“WEBSEARCH FOR A PLANET: THE GOOGLE CLUSTER ARCHITECTURE”&lt;/a&gt;
and &lt;a href=&quot;https://www.elastic.co/guide/en/elasticsearch/reference/current/nodes-shards.html&quot;&gt;Elastic* search&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;SeekStorm moves this very same principle from a macro level to a micro level.&lt;br /&gt;
Instead of &lt;strong&gt;multiple servers&lt;/strong&gt;, with a &lt;strong&gt;shard (index partition) per server&lt;/strong&gt;, we use &lt;strong&gt;multiple processor cores&lt;/strong&gt;, with a &lt;strong&gt;shard (index partition) per processor core&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In both cases, indices are document partitioned across shards during indexing, and partial results from each shard are aggregated during the search into the final results.&lt;/p&gt;

&lt;p&gt;This allows the &lt;strong&gt;full utilization of all processor cores&lt;/strong&gt;, &lt;strong&gt;without synchronization and locking&lt;/strong&gt; losses.&lt;br /&gt;
It &lt;strong&gt;increases the indexing speed&lt;/strong&gt; and &lt;strong&gt;reduces the query latency&lt;/strong&gt; by enabling &lt;a href=&quot;https://link.springer.com/referenceworkentry/10.1007/978-0-387-39940-9_1557&quot;&gt;&lt;strong&gt;intra-query parallelism&lt;/strong&gt;&lt;/a&gt;.&lt;br /&gt;
Indexing time and query latency always scale with the number of shards, whether multiple processor cores, multiple servers, or both.&lt;/p&gt;

&lt;p&gt;A query always touches all shards and processor cores, but the sub-index size and work per shard and processor core are only a fraction compared to an index without shards.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/shards.png&quot; width=&quot;800&quot; alt=&quot;Sharded index architecture&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The beauty of this architectural principle/pattern is that it universally applies for scaling to both multi-server and multi-processor designs.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Seekstorm essentially treats a &lt;strong&gt;processor with many processor cores&lt;/strong&gt; as a &lt;strong&gt;miniature data center with many servers&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That approach becomes more attractive as the &lt;strong&gt;number of cores in modern processors increases&lt;/strong&gt;: e.g. AMD* Ryzen 9 9950X has &lt;strong&gt;16 cores&lt;/strong&gt; (32 threads) or Intel* Core i9 14900 has &lt;strong&gt;24 cores&lt;/strong&gt; (32 threads).&lt;/p&gt;

&lt;p&gt;While in the past search engines were designed with &lt;strong&gt;multithreading as an afterthought&lt;/strong&gt; at best, to fully utilize the power of modern processor architectures require to design search engine architecture with &lt;strong&gt;multithreading-first&lt;/strong&gt; in mind.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;A server almost never runs at full utilization, allowing for headroom to handle traffic spikes and growth. This unused idle computing capacity can be utilized by the sharded index architecture to reduce query (tail) latency.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;challenges-of-bm25-ranking-in-a-sharded-index&quot;&gt;Challenges of BM25 ranking in a sharded index&lt;/h2&gt;

&lt;p&gt;Partitioning a search index in multiple shards can significantly improve both indexing speed and query latency.&lt;br /&gt;
Having independent sub-indices enables intra-query parallelism and allows the utilization of all processor cores without synchronization and locking issues.&lt;/p&gt;

&lt;p&gt;But new challenges arise:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;BM25 scores are only fully comparable within a single shard&lt;/strong&gt;, but not across multiple shards. And they are also not comparable between a sharded index and a non-sharded index, even if the same set of documents is indexed. The reason for this becomes obvious if we look at the BM25 formulae shown below. The BM25 score not only depends on the properties of a given document (like term frequency or document length), but also on values averaged and summarized across all documents in the index or shard. Aggregated BM25 components like the number of documents, posting list length (term frequency), and average document length differ between shards and also between a normal index and a sharded index. When we later aggregate the top-k results of each shard into the final top-k results the &lt;strong&gt;sorting of results by scores from different shards is flawed&lt;/strong&gt;. The more the number and the content of documents indexed differs between the shards, the less comparable are the BM25 scores from different shards.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;The distribution of documents across the shards is not deterministic&lt;/strong&gt; but relies on load-balancing that depends on the current utilization of shards/processor cores. That means aggregated BM25 components, the resulting BM25 scores within shards, and the &lt;strong&gt;final top-k results and their scores are non-deterministic and may change after reindexing&lt;/strong&gt; the same documents.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All those challenges can be overcome, but they add extra complexity on top of a seemingly simple idea.&lt;/p&gt;

&lt;p&gt;For SeekStorm’s sharded index, where documents are evenly distributed across shards, the BM25 scores can be compared between shards. There might be slight differences in the order of results compared to a scoring in a non-sharded index, but those are mainly negliable.&lt;/p&gt;

&lt;p&gt;But when different content distribution strategies are employed, e.g., when a new shard is added on a new node, because the capacity limit of the other shards was reached, then we need to do re-scoring of the top-10 results aggregated from the different shards .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The typical BM25 formula&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;K = 1.2;&lt;br /&gt;
B = 0.75;&lt;br /&gt;
SIGMA = 0.0;&lt;/p&gt;

&lt;p&gt;DF = document frequency = posting_count = posting list length = number of documents containing the term&lt;br /&gt;
TF = term frequency in document = positions_count = positions of term in document = how often occurs term in doc&lt;br /&gt;
IDF = (((indexed_doc_count- DF + 0.5) / (DF + 0.5)) + 1.0).ln(); //log_e&lt;br /&gt;
document_length_quotient= doc_len / avg_doc_len&lt;/p&gt;

&lt;p&gt;BM25 = IDF * ((TF * (K + 1.0) / (TF + (K * (1.0 - B + (B * document_length_quotient))))) + SIGMA);&lt;/p&gt;

&lt;p&gt;The formulae gets slightly more complex if multiple indexed fields are involved and we need to aggregate the BM25 scores per field (BM25f).&lt;/p&gt;

&lt;p&gt;In order to re-score the results from different nodes, we need those components of the BM25 formulae that differ between the shards:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;New fields per top-k result set&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;document_frequencies:Vec&amp;lt;(term_hash,DF)&amp;gt;&lt;/li&gt;
  &lt;li&gt;indexed_doc_count&lt;/li&gt;
  &lt;li&gt;doc_len_sum&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;New fields per top-k result&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;term_frequencies:Vec&amp;lt;(term_hash,TF)&amp;gt;&lt;/li&gt;
  &lt;li&gt;doc_len&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Re-scoring&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We need to calculate the global document_frequencies (DF) per query term by summing the DF from all shards per query term.&lt;/li&gt;
  &lt;li&gt;We need to calculate the global avg_doc_len by dividing the sum of all doc_len_sum from all shards by the sum of all indexed_doc_count from all shards.&lt;/li&gt;
  &lt;li&gt;Then we can use those individual and global values in the BM25 formulae above to re-score the documents coming from different shards on a common base.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;46x-faster-indexing--3x-faster-search&quot;&gt;4..6x faster indexing &amp;amp; 3x faster search&lt;/h2&gt;

&lt;p&gt;SeekStorm’s key advantage is a &lt;strong&gt;faster search at lower infrastructure cost&lt;/strong&gt;. 
Fast search performance is crucial, especially for large indices, which also demand rapid data ingestion.&lt;/p&gt;

&lt;p&gt;Our new &lt;strong&gt;sharded index architecture features&lt;/strong&gt; an index with &lt;strong&gt;document-partitioned shards&lt;/strong&gt;, allowing for &lt;strong&gt;lock-free, multi-threaded indexing&lt;/strong&gt;. 
This fully utilizes all processor cores and increases ingestion speed by a factor of five. The sharded index also enables intra-query concurrency, decreasing average query latency by four times for non-concurrent loads.&lt;/p&gt;

&lt;p&gt;A sharded index enables not only a higher indexing speed but also improves query latency by utilizing all processor cores. But the latter &lt;strong&gt;doesn’t yet utilize its full potential&lt;/strong&gt;. 
&lt;strong&gt;Each shard sees only its own result&lt;/strong&gt;, and can’t access the results retrieved in parallel from other shards for &lt;strong&gt;optimum early termination&lt;/strong&gt;.
The benefit through sharding and parallelization outweighs by far the tunnel vision per shard and the resulting non-optimal early termination.
However, the &lt;strong&gt;full potential&lt;/strong&gt; is only unleashed by &lt;strong&gt;allowing information to be exchanged between shards&lt;/strong&gt; during the search.&lt;/p&gt;

&lt;p&gt;Beginning with release v1.0.0, the SeekStorm lexical search library implements a sharded index, enabling &lt;strong&gt;4..6x faster indexing&lt;/strong&gt; and &lt;strong&gt;3x shorter query latency&lt;/strong&gt; with &lt;strong&gt;intra-query parallelism&lt;/strong&gt;, when comparing SeekStorm v1.0.0 to v0.14.1.
5 million Wikipedia documents are indexed at 40,000 docs/sec (3.5 billion docs/day), and searched with 0.25 ms average query latency, reaching 10,000 queries/sec throughput.&lt;/p&gt;

&lt;p&gt;All of the above has been measured using &lt;a href=&quot;https://github.com/SeekStorm/search-benchmark-game/blob/master/queries.txt&quot;&gt;search_benchmark_game queries&lt;/a&gt; and &lt;a href=&quot;&amp;quot;https://www.dropbox.com/s/wwnfnu441w1ec9p/wiki-articles.json.bz2&amp;quot;&quot;&gt;English Wikipedia corpus&lt;/a&gt;, on a Intel Core i7 13700h laptop.
Of course, &lt;strong&gt;benchmark results highly depend&lt;/strong&gt; on used queries, corpus and hardware, but the results give a clear indication of the improvements achieved since the previous SeekStorm version.&lt;/p&gt;

&lt;h2 id=&quot;benchmark&quot;&gt;Benchmark&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/search_benchmark_game1.png&quot; alt=&quot;Benchmarks&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/search_benchmark_game2.png&quot; alt=&quot;Benchmarks&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/search_benchmark_game3.png&quot; alt=&quot;Benchmarks&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;download&quot;&gt;Download&lt;/h2&gt;

&lt;p&gt;SeekStorm v1.0.0 excels in both indexing and search performance and is available as &lt;strong&gt;open source&lt;/strong&gt; on &lt;a href=&quot;https://github.com/SeekStorm/SeekStorm&quot;&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;roadmap&quot;&gt;Roadmap&lt;/h2&gt;

&lt;p&gt;Currently we support a &lt;strong&gt;single node&lt;/strong&gt; (server) with &lt;strong&gt;multiple local index shards&lt;/strong&gt;. In the next step we will support a &lt;strong&gt;cluster&lt;/strong&gt;, where each shard can be &lt;strong&gt;either a local shard or a remote node&lt;/strong&gt; (dedicated server or cloud) with multiple shards.&lt;br /&gt;
This will allow to &lt;strong&gt;dynamically increase index capacity&lt;/strong&gt; by adding more servers.&lt;/p&gt;

&lt;p&gt;(*) All mentioned trademarks and proper names belong to their respective owners and do not imply any affiliation or any other kind of alliance with their respective owners.&lt;/p&gt;
</description>
        <pubDate>Fri, 04 Apr 2025 00:00:00 +0000</pubDate>
        <link>https://seekstorm.com/blog/SeekStorm-sharded-index-architecture/</link>
        <guid isPermaLink="true">https://seekstorm.com/blog/SeekStorm-sharded-index-architecture/</guid>
        
        
        <category>search</category>
        
        <category>performance</category>
        
        <category>rust</category>
        
        <category>oss</category>
        
      </item>
    
      <item>
        <title>SeekStorm gets Faceted search, Geo proximity search, Result sorting</title>
        <description>&lt;h2 id=&quot;seekstorm-gets-faceted-search-geo-proximity-search-result-sorting&quot;&gt;SeekStorm gets Faceted search, Geo proximity search, Result sorting&lt;/h2&gt;

&lt;p&gt;So far, we have primarily focused on &lt;a href=&quot;2023-12-02-sneak-peek-seekstorm-rust.md&quot;&gt;performance&lt;/a&gt; (latency/throughput) and moved the boundaries of what you can squeeze out of your hardware quite a bit. 
But performance is not all without essential functionality. This time we are adding three major features: Faceted search, Geo proximity search, and Result sorting.&lt;/p&gt;

&lt;p&gt;Adding more features is just grunt work. But ensuring their performance, and combining them with all existing functionality while keeping the performance impact on those low is challenging.
As always, we went the extra mile to reconcile performance and funtionality.&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;faceted-search&quot;&gt;Faceted search&lt;/h1&gt;

&lt;p&gt;Searching is an important part of any business database function.&lt;br /&gt;
The more the amount of data and documents grows that we need to store, index and retrieve, the higher is the risk that we drown in the sheer amount of results, 
and the more important it becomes to refine the search query and filter results to support finding the most relevant documents to us - the needle in a haystack.
This can be done by &lt;strong&gt;adding extra keywords to the query&lt;/strong&gt;, &lt;strong&gt;field search&lt;/strong&gt; which restricts the search within certain specified fields only, or &lt;strong&gt;faceted search&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/deephn_demo.png&quot; width=&quot;800&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://deephn.org/&quot;&gt;DeepHN.org&lt;/a&gt; demo, powered by SeekStorm, makes heavy use of &lt;strong&gt;faceted search&lt;/strong&gt;: for the &lt;strong&gt;domain and hash tag filter&lt;/strong&gt; (string facets), the &lt;strong&gt;comment and points filter&lt;/strong&gt; (numerical range facets) check boxes on the left, as well as the &lt;strong&gt;date range filter and histogram&lt;/strong&gt; (numerical range facets) slider on top.&lt;/p&gt;

&lt;h3 id=&quot;faceted-search-vs-field-search&quot;&gt;Faceted search vs. field search&lt;/h3&gt;

&lt;p&gt;Faceted search is much more than just a field search. Field search allows you to restrict the search within specified fields, 
but requires you to know both &lt;strong&gt;all available fields&lt;/strong&gt; in the indexed documents as well as 
&lt;strong&gt;all unique values per field&lt;/strong&gt;. This leads often to trial and error, leaving the user with no or unsatisfactory results.&lt;/p&gt;

&lt;p&gt;Faceted search is not just a filter, but a complete set of filters is automatically generated/derived from the indexed documents.
Faceted search automatically clusters the indexed documents or search results into categories.
The user can then filter and refine the search results by selecting specific values or numeric ranges for each facet field. 
For each facet field the number of search results matching each distinct facet value or numeric range is shown. 
The difference between field filterinng and faceted search is like between open question and multiple choice.&lt;/p&gt;

&lt;p&gt;As faceted search allows counting and filtering of documents matching specific facet field values, 
it is often used in product search to narrow down and count the search results according to specific product features like brand, manufacturer, rating, or price.&lt;/p&gt;

&lt;h3 id=&quot;index-facets&quot;&gt;Index facets&lt;/h3&gt;

&lt;p&gt;After indexing, the &lt;strong&gt;index facets&lt;/strong&gt; list all available facet fields, their unique values, and count how often a specific value occurs 
&lt;strong&gt;within all indexed documents&lt;/strong&gt;. This provides a complete overview of all filtering options &lt;strong&gt;for the entire index&lt;/strong&gt;, 
  together with quantitative information about the potential result number for each option.&lt;/p&gt;

&lt;h3 id=&quot;query-facets&quot;&gt;Query facets&lt;/h3&gt;

&lt;p&gt;When searching, the &lt;strong&gt;query facets&lt;/strong&gt; list all available facet fields, 
their unique values, and count how often a specific value occurs &lt;strong&gt;within all indexed documents &lt;u&gt;that match a given query&lt;/u&gt;&lt;/strong&gt;. 
This provides a complete overview of all filtering options &lt;strong&gt;for the current result set&lt;/strong&gt;, together with quantitative information about the potential result number for each option.&lt;/p&gt;

&lt;h3 id=&quot;facet-filtering-counting--sorting&quot;&gt;Facet filtering, counting &amp;amp; sorting&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;facet filter&lt;/strong&gt; specified in the query filters the returned results to those documents both matching the query AND matching for all (boolean AND) specified facet filter fields 
at least one (boolean OR) of the specified values.&lt;/p&gt;

&lt;p&gt;If the &lt;strong&gt;query is changed&lt;/strong&gt; and/or the &lt;strong&gt;facet filter is changed&lt;/strong&gt; then both &lt;strong&gt;search results and facet counts are changed&lt;/strong&gt;.&lt;/p&gt;

&lt;h4 id=&quot;string-facets-fieldtypestring&quot;&gt;String Facets (FieldType::String)&lt;/h4&gt;

&lt;p&gt;E.g. the &lt;strong&gt;Language field&lt;/strong&gt; of a document may have different values: e.g. English, French, German, Russian, Chinese.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;String facet counting&lt;/strong&gt;: Each distinct value is counted across all indexed documents (&lt;strong&gt;index facet&lt;/strong&gt;) or all results documents (&lt;strong&gt;query facet&lt;/strong&gt;).
The string facets return both information about &lt;strong&gt;which languages exist&lt;/strong&gt; and &lt;strong&gt;how often they occur&lt;/strong&gt;, 
within all indexed documents (&lt;strong&gt;index facet&lt;/strong&gt;) or within in all documents that match the query (&lt;strong&gt;query facet&lt;/strong&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Facet sorting&lt;/strong&gt;: The values within each facet field are sorted by the number of their occurrences in the documents in descending order. 
The number of returned values per facet field can be limited by the parameter &lt;strong&gt;facetvalueslength&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Search result filtering&lt;/strong&gt;: Besides &lt;strong&gt;counting&lt;/strong&gt;, we may also &lt;strong&gt;filter&lt;/strong&gt; the results to return only those documents, where the &lt;strong&gt;Language field&lt;/strong&gt; contains specific language values e.g. English or French.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Search result sorting&lt;/strong&gt;: The returned search results can be sorted by the (first) value of the specified &lt;strong&gt;facet field&lt;/strong&gt; of a document in ascending or descending order.
If no &lt;strong&gt;sort&lt;/strong&gt; field is specified, then the results are sorted by rank in descending order per default.&lt;/p&gt;

&lt;p&gt;SeekStorm supports the &lt;strong&gt;String&lt;/strong&gt; field type for &lt;strong&gt;String Facet&lt;/strong&gt; counting, filtering &amp;amp; sorting.&lt;/p&gt;

&lt;h4 id=&quot;multi-value-string-facets-fieldtypestringset&quot;&gt;Multi-value string facets (FieldType::StringSet)&lt;/h4&gt;

&lt;p&gt;Similar to String facets, but while string facets allow only one value per field per document, String Set facets allow to assign multiple values at the same time per field per document.
Great for e.g. genres, authors, languages, educations, product categories, tags …, where an item can be associated with multiple values of a field.&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;// index document&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;document_json&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;
{&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;movie&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Casablanca&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,
&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Casablanca&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1942&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;American&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;romantic&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;drama&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;film&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,
&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;year&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:1942,
&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;genre&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:[&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;romance&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;drama&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;],
&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actors&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:[&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Humphrey&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Bogart&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Ingrid&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Bergman&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Paul&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Henreid&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;],
&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subtitles&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:[&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;English&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;French&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;German&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;]}&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;serde_json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;from_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;document_json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;index_arc&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.index_document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.await&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; 
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;numerical-range-facets-fieldtypeu8fieldtypef64&quot;&gt;Numerical Range Facets (FieldType::U8…FieldType::F64)&lt;/h4&gt;

&lt;p&gt;In contrast to &lt;strong&gt;string facets&lt;/strong&gt; which define themselves by the existing distinct values, for &lt;strong&gt;range facets&lt;/strong&gt; we have to explicitly &lt;strong&gt;define the ranges&lt;/strong&gt; we want to distinguish and count.
E.g. for the &lt;strong&gt;Price field&lt;/strong&gt; we want to define price ranges: e.g. 0..10 USD, 10..20 USD, 20..50 USD, 50..100 USD, 100..1000 USD. The ranges may be defined differently for each query.&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_query_facets&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;

    &lt;span class=&quot;nn&quot;&gt;QueryFacet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;vintage-car-brand&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;prefix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;u16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;

    &lt;span class=&quot;nn&quot;&gt;QueryFacet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;U8&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;car-age&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;range_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;RangeType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CountWithinRange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;ranges&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0-20&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;20-40&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;40-60&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;60-80&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;80-100&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Range facet counting&lt;/strong&gt;: Across all results documents (query facet) it is then counted how often a price value falls within one of the defined price ranges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Search result filtering&lt;/strong&gt;: Besides &lt;strong&gt;counting&lt;/strong&gt;, we may also &lt;strong&gt;filter&lt;/strong&gt; the results to return only those documents, where the &lt;strong&gt;Price field&lt;/strong&gt; value is within the range of 15..25 USD.
The filter range is independent from the defined range facets for counting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Search result sorting&lt;/strong&gt;: The returned search results can be sorted by the value of the specified &lt;strong&gt;integerFacet, floatFacet, or dateFacet field&lt;/strong&gt; of a document in ascending or descending order.
If no &lt;strong&gt;sort&lt;/strong&gt; field is specified, then the results are sorted by rank in descending order per default.&lt;/p&gt;

&lt;p&gt;SeekStorm supports &lt;strong&gt;u8, u16, u32, u64, i8, i16, i32, i64, f32, f64&lt;/strong&gt; field types for &lt;strong&gt;Numerical Range Facet&lt;/strong&gt; counting, filtering &amp;amp; sorting.&lt;/p&gt;

&lt;h3 id=&quot;performance&quot;&gt;Performance&lt;/h3&gt;

&lt;p&gt;Faceted search is known to have a heavy impact on search performance. For SeekStorm performance and scaling are always paramount, also for faceted search. 
We went the extra mile to optimize our index architecture so that faceting has only &lt;strong&gt;low impact on the search performance&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/faceted_search.png&quot; width=&quot;800&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;result-sort-by-any-field&quot;&gt;Result sort by any field&lt;/h1&gt;

&lt;p&gt;SeekStorm v0.4.0 allows &lt;strong&gt;result sorting by any field&lt;/strong&gt;, both &lt;strong&gt;ascending or descending&lt;/strong&gt; - &lt;strong&gt;multiple sort fields are combined by tie-break&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;After all sort fields are considered, the results are sorted by BM25 score as last clause.&lt;br /&gt;
If no sort fields are stated, then the results are just sorted by BM25 score.
Currently, sorting by fields is more expensive than sorting by BM25 alone, as it prevents WAND search acceleration.&lt;/p&gt;

&lt;p&gt;Define result sort&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result_sort&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ResultSort&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;order&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;SortOrder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Ascending&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;FacetValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h1 id=&quot;geo-proximity-search&quot;&gt;Geo proximity search&lt;/h1&gt;

&lt;p&gt;For the new &lt;strong&gt;Geo proximity search&lt;/strong&gt;, you may provide a reference coordinate point to &lt;strong&gt;sort results&lt;/strong&gt; by the &lt;strong&gt;Euclidean distance&lt;/strong&gt; (with Equirectangular approximation) between the specified coordinate fields and reference coordinate. The &lt;strong&gt;distance in kilometers or miles&lt;/strong&gt; can be automatically calculated and inserted in the result document. 
&lt;strong&gt;Result filtering&lt;/strong&gt; now also supports &lt;strong&gt;Euclidean distance&lt;/strong&gt; between the specified coordinate fields and a reference coordinate.
The Morton code encoding and decoding is accelerated by BMI2 processor intrinsics, if available&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;New field type Point: array of 2 * f64 coordinate values (longitude and latitude) as defined in https://geojson.org.&lt;br /&gt;
Internally encoded into a single 64 bit Morton code for efficient range queries.&lt;br /&gt;
get_facet_value decodes Morton code back to Point.&lt;/li&gt;
  &lt;li&gt;New public methods: encode_morton_2_d(point:&amp;amp;Point)-&amp;gt;u64, decode_morton_2_d(code: u64)-&amp;gt;Point,&lt;br /&gt;
euclidian_distance(point1: &amp;amp;Point, point2: &amp;amp;Point, unit: &amp;amp;DistanceUnit)-&amp;gt;f64,&lt;br /&gt;
point_distance_to_morton_range(point: &amp;amp;Point,distance: f64,unit: &amp;amp;DistanceUnit)-&amp;gt; Range&lt;u64&gt;&lt;/u64&gt;&lt;/li&gt;
  &lt;li&gt;New property ResultSort.base that allows to specify a query base value (e.g. of type Point for current location coordinate) during search.&lt;br /&gt;
Then results won’t be ordered by the field values but by the distance between the field value and query base value, e.g. for geo proximity search.&lt;/li&gt;
  &lt;li&gt;New parameter distance_fields: &amp;amp;Vec&lt;DistanceField&gt; for the get_document method allows to insert distance fields into result documents,  
calculating the distance between a specified facet field of type Point and a base Point, in kilometers or miles,  
using Euclidian distance (Pythagoras theorem) with Equirectangular approximation.&lt;/DistanceField&gt;&lt;/li&gt;
  &lt;li&gt;SearchRequestObject in query_index_api and GetDocumentRequest in get_document_api (server REST API) have a new property distance_fields: Vec&lt;DistanceField&gt;.&lt;/DistanceField&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;get_facet_value()&lt;/strong&gt; : Returns value from facet field for a doc_id even if schema stored=false (field not stored in document JSON).&lt;br /&gt;
Facet fields are more compact than fields stored in document JSON.
Facet fields are faster because no document loading, decompression and JSON decoding is required.&lt;br /&gt;
Facet fields are always memory mapped, internally always stored with fixed byte length layout.
Facet fields are instantly updatable without re-indexing the whole document.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Define range query facet&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_facets&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;QueryFacet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Point&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;location&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;38.8951&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; -&lt;span class=&quot;mf&quot;&gt;77.0364&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;unit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;DistanceUnit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Kilometers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;range_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;RangeType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CountWithinRange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ranges&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0-200&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;200-400&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;200.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;400-600&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;400.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;600-800&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;600.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;800-1000&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;800.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Define facet filter&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;facet_filter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;FacetFilter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Point&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;location&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;38.8951&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; -&lt;span class=&quot;mf&quot;&gt;77.0364&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1000.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;DistanceUnit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Kilometers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Define result sort by proximity&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result_sort&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ResultSort&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;location&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;order&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;SortOrder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Ascending&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;FacetValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;38.8951&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; -&lt;span class=&quot;mf&quot;&gt;77.0364&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Calculate and insert distance field into result document&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;distance_fields&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DistanceField&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;location&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;distance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;distance&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;38.8951&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; -&lt;span class=&quot;mf&quot;&gt;77.0364&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;unit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;DistanceUnit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Kilometers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}];&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index_ref&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index_arc_clone&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.await&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result_object&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.results&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.iter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index_ref&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.get_document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.doc_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;highlighter_option&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;return_fields_filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;distance_fields&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; 
    &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Display query facets&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;{}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;  &lt;span class=&quot;nn&quot;&gt;serde_json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_string_pretty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result_object&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.facets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;relevant-api-endpoints&quot;&gt;Relevant API endpoints&lt;/h3&gt;

&lt;h4 id=&quot;create-index&quot;&gt;&lt;a href=&quot;https://docs.rs/seekstorm/latest/seekstorm/#create-index&quot;&gt;Create index&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Facet fields allow counting, filtering, and sorting of indexed documents matching specific &lt;strong&gt;facet field values&lt;/strong&gt; or &lt;strong&gt;numeric ranges&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create index&lt;/strong&gt;: Facet fields are defined in the &lt;strong&gt;schema&lt;/strong&gt; parameter of &lt;strong&gt;create_index&lt;/strong&gt; by setting the &lt;strong&gt;field_type&lt;/strong&gt; to one of the following types:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nb&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;u16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;u32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;u64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;i8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;i16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;i32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;i64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;f32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;f64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Point&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;and set&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;s&quot;&gt;&quot;facet&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;true&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;in the schema (see code below).&lt;/p&gt;

&lt;p&gt;Faceting can be enabled both for string field type and numerical field types.
Both numerical, string and text fields can be indexed (field_indexed=true) and stored (field_stored=true) in the json document,
but with field_facet=true a numerical or string field is additionally stored in a binary format, for fast faceting and sorting without document store access (decompression, deserialization).
Setting a numerical field to “facet”:true is also the precondition for sorting the search result by this fields value (‘score’ is treated as a special field to allow sorting by relevancy).&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index_path&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;C:/index/&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;schema_json&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;
[{&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field_type&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stored&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:false,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;indexed&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:false},
{&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field_type&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stored&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:true,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;indexed&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:true},
{&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field_type&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stored&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:true,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;indexed&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:false},
{&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;town&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field_type&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stored&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:false,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;indexed&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:false,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;facet&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:true}]&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;schema&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;serde_json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;from_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;schema_json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IndexMetaObject&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test_index&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;SimilarityType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Bm25f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;TokenizerType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AsciiAlphabetic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;access_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;AccessType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Mmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;serialize_schema&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;segment_number_bits1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;create_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;schema&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;serialize_schema&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;segment_number_bits1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index_arc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;RwLock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;index-documents&quot;&gt;&lt;a href=&quot;https://docs.rs/seekstorm/latest/seekstorm/#index-documents&quot;&gt;Index document(s)&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;While the &lt;strong&gt;type&lt;/strong&gt; of the facet fields (u8, u16, u32, u64, i8, i16, i32, i64, f32, f64, String, StringSet, Point) is defined in &lt;strong&gt;create index&lt;/strong&gt;, the &lt;strong&gt;value&lt;/strong&gt; of those fields
is defined and indexed with &lt;strong&gt;index document&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Index document request object&lt;/strong&gt;: Each facet field can be assigned a single string values or numerical value per document:&lt;br /&gt;&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;documents_json&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;
[{&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body1&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url1&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;town&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Berlin&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;},
{&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title2&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url2&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;town&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Warsaw&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;},
{&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title3&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body3&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url3&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;town&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;:&quot;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;New&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;York&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;}]&quot;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;documents_vec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;serde_json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;from_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;documents_json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;index_arc&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.index_documents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;documents_vec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.await&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In addition to the facet functionality (counting, filtering, sorting) the facet value can be also indexed to full-text search.&lt;br /&gt;
The number of distinct values per string facet field, across the whole index, is limited to 65,535.&lt;br /&gt;
The number of distinct value combinations per string set facet field, across the whole index, is limited to 65,535.&lt;br /&gt;
The string length of a stringFacet value is limited to 100 characters.&lt;/p&gt;

&lt;h4 id=&quot;get-index-string-facets&quot;&gt;&lt;a href=&quot;https://docs.rs/seekstorm/latest/seekstorm/index/struct.Index.html#method.get_index_string_facets&quot;&gt;Get index string facets&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;get_index_string_facets&lt;/strong&gt;: list of string facet fields, each with field name and a map of unique values and their count (number of times the specific value appears in the whole index).&lt;br /&gt;
Values are sorted by their occurrence count within all indexed documents in descending order.&lt;br /&gt; 
The string facets returned with get_index_string_facets are defined and created at index time, not at query time.&lt;br /&gt; 
They contain the facet values of the whole index, not only the documents matching a specific query.&lt;br /&gt; 
Therefore only string facets can be returned with get_index_string_facets, while numerical range facets are defined at query time and can’t be generated at index time.&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_facets&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;nn&quot;&gt;QueryFacet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;prefix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;u16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string_facets&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.get_index_string_facets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;query_facets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;{}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;serde_json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_string_pretty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string_facets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;query_facets filter&lt;/strong&gt;: If there are many distinct values per facet field, we might want to filter the returned values to those matching a given prefix or limiting the number of returned distinct values.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;prefix&lt;/strong&gt; property of a QueryFacet allows to filter the returned facet values to those matching a given prefix, if there are too many distinct values per facet field.&lt;br /&gt;
The &lt;strong&gt;length&lt;/strong&gt; property of a QueryFacet allows limiting the number of returned distinct values per facet field, if there are too many distinct values. With length=0 no facts are returned at all.&lt;br /&gt;
The values are sorted by the frequency of the appearance of the value within the indexed documents matching the query in descending order.&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_facets&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;nn&quot;&gt;QueryFacet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;language&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;prefix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;ger&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;get_index_string_facets&lt;/strong&gt; returns a &lt;strong&gt;vector of index facets&lt;/strong&gt;. For all facet fields, it is counted how often each distinct value occurs &lt;strong&gt;within all indexed documents&lt;/strong&gt;.&lt;br /&gt;
Within each facet field, the values are sorted by their occurrence count &lt;strong&gt;within all indexed documents&lt;/strong&gt; in descending order.&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;field&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;fruit&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;values&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Apple&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;41912&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Pear&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;41863&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Cherry&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;41524&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Orange&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;41516&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Plum&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;41502&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Range facets&lt;/strong&gt; for numerical values are returned with &lt;strong&gt;query documents&lt;/strong&gt;, 
where the ranges can be defined dynamically with different boundaries for each query. This allows defining facets ranges like Last hour, last day, last week, last month.&lt;br /&gt;&lt;/p&gt;

&lt;h4 id=&quot;search-index&quot;&gt;&lt;a href=&quot;https://docs.rs/seekstorm/latest/seekstorm/#search-index&quot;&gt;Search index&lt;/a&gt;&lt;/h4&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;QueryType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Intersection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; 
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result_type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;ResultType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TopkCount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;include_uncommitted&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;field_filter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_facets&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;QueryFacet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prefix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;u16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MAX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}];&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;facet_filter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result_object&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index_arc&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.search&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;include_uncommitted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field_filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;query_facets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;facet_filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.await&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;display results&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;highlights&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Highlight&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;Highlight&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;body&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.to_owned&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;fragment_number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;fragment_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;160&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;highlight_markup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;    

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;highlighter2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;highlighter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;highlights&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result_object&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.query_terms&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;return_fields_filter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;HashSet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index_arc&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.await&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result_object&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.results&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.iter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.get_document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.doc_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;highlighter2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;return_fields_filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;result {} rank {} body field {:?}&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.doc_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doc&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;body&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;display facets&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;{}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;serde_json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_string_pretty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result_object&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.facets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;: The query defines which of the indexed documents are returned  as search results.&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;  &lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;query_facets&lt;/strong&gt;: The query_facets parameter specifies for both for string facets and numerical range facets which facet field to return at query time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;String facets&lt;/strong&gt; allow to filter the returned string facet values by prefix and maximum number.
If there are many distinct values per facet field, we might want to filter the returned values to those matching a given prefix or limiting the number of returned distinct values.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;prefix&lt;/strong&gt; property of a QueryFacet allows to filter the returned facet values to those matching a given prefix, if there are too many distinct values per facet field.&lt;br /&gt;
The &lt;strong&gt;length&lt;/strong&gt; property of a QueryFacet allows limiting the number of returned distinct values per facet field, if there are too many distinct values. With length=0 no facts are returned at all.&lt;br /&gt;
With length=0 no query facets are returned, but facet filtering can still be used.&lt;br /&gt;
With no facet filter defined the query faceting is completely disabled, resulting in slightly better query performance.&lt;br /&gt;
The values are sorted by the frequency of the appearance of the value within the indexed documents matching the query in descending order.&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_facets&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;nn&quot;&gt;QueryFacet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;language&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;prefix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;ger&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Numerical range facets&lt;/strong&gt; require to &lt;strong&gt;define the ranges&lt;/strong&gt; we want to distinguish and count and their labels at query time.&lt;/p&gt;

&lt;p&gt;The ranges can be defined arbitrarily. Different bucket widths are allowed within the same range facet field.&lt;br /&gt;
The &lt;strong&gt;lower boundary&lt;/strong&gt; is defined explicitly (including the number itself).&lt;br /&gt; 
The &lt;strong&gt;upper boundary&lt;/strong&gt; is defined implicitly by the following boundary (excluding the number itself) or the maximum value allowed for the numeric type.&lt;/p&gt;

&lt;p&gt;The ranges may be defined differently for each query. 
This allows to define facets ranges like last hour=current date - 1 hour, last day=current date - 24 hours, last week=current date - 168 hours, 
last month=current date - 5040 hours, where the meaning of &lt;strong&gt;last hour&lt;/strong&gt; changes dynamically, 
when you look at the absolute value of the date of the indexed documents you want to include in the results. The number of distinct ranges per range facet field is limited to 65_536, excess ranges are ignored.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;range_type&lt;/strong&gt; property of a QueryFacet allows to specify how to count the frequency of numerical facet field values: &lt;strong&gt;within the specified range&lt;/strong&gt;, &lt;strong&gt;within the range and all ranges above&lt;/strong&gt;, or &lt;strong&gt;within the range and all ranges below&lt;/strong&gt;.&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;enum&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RangeType&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CountWithinRange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CountAboveRange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CountBelowRange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_facets&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;QueryFacet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;U8&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;range_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;RangeType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CountWithinRange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ranges&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0-20&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;20-40&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;40-60&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;60-80&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;80-100&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;facet_filter&lt;/strong&gt;: Search results are filtered to documents matching specific values in the facet fields.&lt;/p&gt;

&lt;p&gt;The filter parameter filters the returned results to those documents both matching the query AND matching for all (boolean AND) stated facet filter fields 
at least one (boolean OR) of the stated values.&lt;/p&gt;

&lt;p&gt;If the &lt;strong&gt;query is changed&lt;/strong&gt; and/or the &lt;strong&gt;facet filter is changed&lt;/strong&gt; then both &lt;strong&gt;search results and facet counts are changed&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;String facet filter&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;facet_filter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;FacetFilter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;62&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()],&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Numerical range facet filter&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;facet_filter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;FacetFilter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;U8&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;21&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;65&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;result_sort&lt;/strong&gt;: Search results can be sorted by any numerical facet field, either in ascending or descending order.&lt;/p&gt;

&lt;p&gt;If no sort field is specified, then the search results are sorted by rank in descending order per default.&lt;br /&gt;
If there are multiple sort field specified, then the results are ordered by the first field, and then by the second field (tie-break).&lt;br /&gt;
A special _score field (BM25x), reflecting how relevant the result is for a given search query (phrase match, match in title etc.) can be combined with any of the other sort fields as primary, secondary or n-th sort criterion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result sort&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result_sort&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ResultSort&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;order&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;SortOrder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Ascending&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;FacetValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}];&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Query facets result object&lt;/strong&gt;: Query facets with counts for all distinct values are returned in &lt;strong&gt;facets&lt;/strong&gt; property of the search result.&lt;/p&gt;

&lt;p&gt;For all facet fields, it is counted how often each distinct value occurs &lt;strong&gt;within all indexed documents matching the query&lt;/strong&gt;.
If the query is &lt;strong&gt;not empty&lt;/strong&gt;, then sorted/filtered &lt;strong&gt;query facets&lt;/strong&gt; are returned.
If the query is &lt;strong&gt;empty&lt;/strong&gt;, then sorted/filtered &lt;strong&gt;index facets&lt;/strong&gt; are returned (like with get_index_string_facets).&lt;/p&gt;

&lt;p&gt;Within each facet field, the values are sorted by their occurrence count &lt;strong&gt;within all indexed documents matching the query&lt;/strong&gt; in descending order.
Numerical range &amp;amp; String value facet counting depend both on the query and on the applied range &amp;amp; string facet filtering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;String facet result&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;field&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;fruit&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;values&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Apple&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;41912&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Pear&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;41863&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Cherry&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;41524&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Orange&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;41516&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Plum&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;41502&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Numerical range facet result&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;field&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;age&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;values&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;0-20&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;834014&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;20-40&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;834091&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;40-60&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;833311&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;60-80&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;833288&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;80-100&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;833363&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Enjoy, and let us know what features you want to see next!&lt;/strong&gt;&lt;/p&gt;
</description>
        <pubDate>Fri, 20 Sep 2024 00:00:00 +0000</pubDate>
        <link>https://seekstorm.com/blog/faceted_search-geo-proximity-search/</link>
        <guid isPermaLink="true">https://seekstorm.com/blog/faceted_search-geo-proximity-search/</guid>
        
        
        <category>search</category>
        
        <category>performance</category>
        
        <category>rust</category>
        
        <category>oss</category>
        
      </item>
    
      <item>
        <title>SeekStorm is now Open Source</title>
        <description>&lt;h2 id=&quot;seekstorm-sub-millisecond-full-text-search-rust-is-now-open-source&quot;&gt;SeekStorm sub-millisecond full-text search (Rust) is now Open Source&lt;/h2&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;SeekStorm is an &lt;strong&gt;open source&lt;/strong&gt;, &lt;strong&gt;sub-millisecond full-text search library&lt;/strong&gt; &amp;amp; &lt;strong&gt;multi-tenancy server&lt;/strong&gt; implemented in &lt;strong&gt;Rust&lt;/strong&gt;.&lt;/p&gt;

&lt;h3 id=&quot;porting-from-c-to-rust---why&quot;&gt;Porting from C# to Rust - why?&lt;/h3&gt;

&lt;p&gt;Porting the SeekStorm codebase from C# to Rust&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Factor 2..4x performance gain (latency and throughput)&lt;/li&gt;
  &lt;li&gt;No slow first run (no cold start costs due to just-in-time compilation)&lt;/li&gt;
  &lt;li&gt;Stable latencies (no garbage collection delays)&lt;/li&gt;
  &lt;li&gt;Less memory consumption (no ramping up until the next garbage collection)&lt;/li&gt;
  &lt;li&gt;Steep learning curve (previously development time divided between designing algorithms and debugging, now between translating and fighting with the compiler borrow checker)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rust is great for performance-critical applications 🚀 that deal with big data and/or many concurrent users. Fast algorithms will shine even more with a performance-conscious programming language 🙂&lt;/p&gt;

&lt;p&gt;But we didn’t stop at faithfully porting all the code from C# to Rust. It has been a redesign of architecture and algorithms, incorporating everything we learned from 4 years of operating SeekStorm in production
as a multi-tenancy search-as-a-service.&lt;/p&gt;

&lt;h3 id=&quot;why-another-search-library-performance-and-scalability-without-the-cost&quot;&gt;Why another search library? Performance and scalability without the cost.&lt;/h3&gt;

&lt;p&gt;Despite what the hype cycles want you to believe, Keyword search is here to stay, right beside vector search and LLMs.&lt;/p&gt;

&lt;p&gt;Keyword/Lexical search is such a basic/fundamental technology, that has countless application fields and still excels in many areas due to its simplicity, universality, and performance.
But even a mature technology like keyword search which has been there for decades, is still open to innovation in architecture and algorithms that enable performance improvements by an order of magnitude to make it fit for the next decades to come.&lt;/p&gt;

&lt;p&gt;The amount of data produced is growing exponentially, and more and more applications rely on processing those data at a massive scale, without sacrificing performance. 
The scalability of your search infrastructure has to keep up. Sure, you can always add more servers, shards, and replicas. This increases the complexity, cost, and energy consumption.
But like LED technology can produce the same amount of light as incandescent bulbs with much less energy and cost, technology can achieve the same efficiency leap for search.&lt;/p&gt;

&lt;h3 id=&quot;why-search-performance-is-so-important&quot;&gt;Why search performance is so important&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Search speed might be good enough for a single search. Below &amp;lt;10 ms people can’t tell latency anymore. Also, search latency might be small compared to Internet network latency.&lt;/li&gt;
  &lt;li&gt;But search engine performance still matters when used in a server or service for many concurrent users and requests for maximum scaling, and throughput, and low processor load, cost.&lt;/li&gt;
  &lt;li&gt;With performant search technology you can serve many concurrent users, at low latency with fewer servers, less cost, and less energy consumption, lower carbon footprint.&lt;/li&gt;
  &lt;li&gt;It also ensures low latency even for complex and challenging queries: instant search, fuzzy search, faceted search, and union/intersection/phrase of very frequent terms.&lt;/li&gt;
  &lt;li&gt;Besides average latencies we also need to reduce tail latencies, which are often overlooked, but can cause a loss of customers, and revenue and can lead to a bad user experience.&lt;/li&gt;
  &lt;li&gt;It is always advisable to engineer your search infrastructure with enough performance headroom, to keep those tail latencies in check, even on periods or spikes of high concurrent load.&lt;/li&gt;
  &lt;li&gt;Also, even if a human user might not notice the latency, it still might make a big difference in autonomous stock markets or defense applications or RAG which requires multiple queries.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;open-source&quot;&gt;Open source&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Rust port&lt;/strong&gt; of the &lt;strong&gt;SeekStorm sub-millisecond full-text search library and multi-tenancy server&lt;/strong&gt; is &lt;strong&gt;open-sourced under Apache License 2.0&lt;/strong&gt; and available on &lt;a href=&quot;https://github.com/SeekStorm/SeekStorm&quot;&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://github.com/SeekStorm/SeekStorm&quot;&gt;SeekStorm port to Rust&lt;/a&gt; is our fourth and largest open-source project after &lt;a href=&quot;https://github.com/wolfgarbe/SymSpell&quot;&gt;SymSpell&lt;/a&gt;, &lt;a href=&quot;https://github.com/wolfgarbe/PruningRadixTrie&quot;&gt;PruningRadixTrie&lt;/a&gt;, and &lt;a href=&quot;https://github.com/wolfgarbe/WordSegmentationTM&quot;&gt;WordSegmentationTM&lt;/a&gt;.
All four projects have been performance-oriented and pushed the boundaries of the previous state-of-the-art by quite a bit.&lt;/p&gt;

&lt;p&gt;With a combined &lt;strong&gt;3,500 stars on Github&lt;/strong&gt;, all projects have been quite popular, and we hope you will like our search solution as well, whether as a hosted service or an open-source library.&lt;/p&gt;

&lt;h3 id=&quot;benchmarks&quot;&gt;Benchmarks&lt;/h3&gt;

&lt;p&gt;The first benchmarks of the Rust port of the SeekStorm sub-millisecond full-text search library and multi-tenancy server are in. 
Still preliminary, currently porting intra-query concurrency, LSM-trie, faceted search and updating documentation.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/search_benchmark_game1.png&quot; alt=&quot;Benchmarks&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/search_benchmark_game2.png&quot; alt=&quot;Benchmarks&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Open-source search engine libraries (BM25 lexical search) are compared using the open-source search_benchmark_game developed by &lt;a href=&quot;https://github.com/quickwit-oss/search-benchmark-game/&quot;&gt;Tantivy&lt;/a&gt; and &lt;a href=&quot;https://github.com/jason-wolfe/search-index-benchmark-game&quot;&gt;Jason Wolfe&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://seekstorm.github.io/search-benchmark-game/&quot;&gt;Detailled benchmark results&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/SeekStorm/search-benchmark-game&quot;&gt;Benchmark code repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Indexing test data: The benchmark is based on the &lt;a href=&quot;https://www.dropbox.com/s/wwnfnu441w1ec9p/wiki-articles.json.bz2&quot;&gt;English Wikipedia corpus&lt;/a&gt; (5,032,105 documents, 8,28 GB decompressed).&lt;/p&gt;

&lt;p&gt;wiki-articles.json has a .JSON extension, but it is not a valid JSON file. It is a text file, where every line contains a JSON object with url, title and body attributes. 
The format is called &lt;a href=&quot;http://ndjson.org/&quot;&gt;ndjson&lt;/a&gt;, also referred to as “Newline delimited JSON”.&lt;/p&gt;

&lt;p&gt;Query test data: the benchmark uses &lt;a href=&quot;https://github.com/quickwit-oss/search-benchmark-game/blob/master/queries.txt&quot;&gt;queries&lt;/a&gt; derived from the &lt;a href=&quot;https://en.wikipedia.org/wiki/AOL_search_data_leak&quot;&gt;AOL query dataset&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hardware: Thinkpad P1, 64,0 GB RAM, Intel Core i7-13700H 2.40 GHz, 2TB Hynix NVMe SSD&lt;/p&gt;

&lt;h3 id=&quot;multi-field-search&quot;&gt;Multi-field search&lt;/h3&gt;

&lt;p&gt;Multi-field search at almost no performance cost is desirable, but can’t be taken for granted with every search library.&lt;/p&gt;

&lt;p&gt;While some benchmarks focus solely on search within a single field, those results are not very representative of real-world use cases.
In most cases, we need to search through multiple fields at the same time. 
How much this influences the performance, namely latency and throughput, highly depends on the used data structures and algorithms of the search library.&lt;/p&gt;

&lt;p&gt;Often, the number of terms in the (e.g.) title field is negligible compared to the (e.g.) body field, yet searching through both fields can be expensive in some search libraries.&lt;/p&gt;

&lt;p&gt;Btw., concatenating both fields before indexing is not a viable solution because it prohibits BM25F scoring, where matches in a shorter title field should receive a higher score.&lt;/p&gt;

&lt;h3 id=&quot;concurrent-queries-the-standard-use-case&quot;&gt;Concurrent queries: the standard use case&lt;/h3&gt;

&lt;p&gt;While most search benchmarks still focus on single-field, single-user tests the much more realistic real-world use case is a multi-field index, with concurrent queries.
Unless you have a local single-user installation on your notebook you will usually have many concurrent users accessing your server.
Not only is this the most frequent use case, but it allows also you to test whether your architecture utilizes and saturates all processor cores for increased throughput and low latency.
If that’s the main use case then we should also benchmark exactly this scenario and make technology decisions based on those results.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/benchmark_3.jpg&quot; alt=&quot;Benchmarks&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/blog/assets/images/benchmark_4.jpg&quot; alt=&quot;Benchmarks&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;relevancy&quot;&gt;Relevancy&lt;/h3&gt;

&lt;p&gt;Many search libraries still use Okapi BM25 as the default ranking function, though it doesn’t work well for phrase search, as it doesn’t consider the proximity and order of query terms.&lt;/p&gt;

&lt;p&gt;Sure, you can select a different scorer or customize it, but why force your users to do a deep dive into documentation, and information retrieval, and reinvent, what should have been the default in the first place?&lt;/p&gt;

&lt;p&gt;Also, why would you force your users to formulate an explicit phrase search with “” just to get a phrase-aware scoring (not filtering)?
Phrase-aware ranking should be the default, whether or not the user is explicitly using “”.&lt;/p&gt;

&lt;p&gt;Wouldn’t it be better to assist the user on every step, and make search as painless and successful as possible, even without being an expert?&lt;/p&gt;

&lt;p&gt;Query: &lt;strong&gt;the who&lt;/strong&gt;&lt;br /&gt;
&lt;img src=&quot;/blog/assets/images/ranking.jpg&quot; alt=&quot;Benchmarks&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;key-contributions&quot;&gt;Key contributions&lt;/h3&gt;

&lt;p&gt;SeekStorm significantly improves the query performance compared to the current state of the art in the following areas:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;query type&lt;/th&gt;
      &lt;th&gt;number of searched fields (title+body vs. body) &lt;/th&gt;
      &lt;th&gt;concurrent queries&lt;/th&gt;
      &lt;th&gt;factor vs. Tantivy&lt;/th&gt;
      &lt;th&gt;factor vs. Lucene&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;all&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;4.7x&lt;/td&gt;
      &lt;td&gt;4.6x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;all&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;2.8x&lt;/td&gt;
      &lt;td&gt;5.5x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;union&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;6.1x&lt;/td&gt;
      &lt;td&gt;7.4x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;union&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;4.5x&lt;/td&gt;
      &lt;td&gt;10.1x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;intersection&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;5.8x&lt;/td&gt;
      &lt;td&gt;1.8x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;intersection&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;1x&lt;/td&gt;
      &lt;td&gt;1.6x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;single frequent term (‘the’)&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;286.7x&lt;/td&gt;
      &lt;td&gt;734.1x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;single frequent term (‘the’)&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;336.7x&lt;/td&gt;
      &lt;td&gt;719.6x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;two-phase-critic (+”the who” +uk)&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;700.6x&lt;/td&gt;
      &lt;td&gt;191.3x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;two-phase-critic (+”the who” +uk)&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;835.2x&lt;/td&gt;
      &lt;td&gt;174.8x&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;a href=&quot;https://seekstorm.github.io/search-benchmark-game/&quot;&gt;Detailled benchmark results&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3 id=&quot;keyword-search-is-here-to-stay-right-beside-vector-search-and-llms&quot;&gt;Keyword search is here to stay, right beside vector search and LLMs&lt;/h3&gt;

&lt;p&gt;Despite what the hype-cycles want you to believe, &lt;strong&gt;keyword search is not dead or outdated&lt;/strong&gt;, as NoSql wasn’t the death of Sql, and bloom filters didn’t make hashsets obsolete.&lt;/p&gt;

&lt;p&gt;We all share the excitement whenever a new technology surfaces, that offers radical new capabilities.&lt;/p&gt;

&lt;p&gt;But those are all just tools in a toolbox, where there is no one-fits-all tool. Time-proven doesn’t mean outdated.&lt;/p&gt;

&lt;p&gt;Sure, new technologies will take over in some areas where they are better suited. And then there is some overlap in application fields, where either of the tools might have an advantage, depending on what your exact requirements are: performance, exactness, completeness, grasp of meaning and synonyms, zero-shot, out-of-vocabulary, and real-time capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But the more basic/fundamental a technology is, the more likely it is there to stay and still excel in many areas due to its simplicity, universality, and performance.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At its core, keyword search is just a filter for a set of documents, returning those where certain keywords occur, usually combined with a ranking metric like BM25.
A very basic and core functionality, that is very challenging to implement at scale with low latency.
Because the functionality is so basic, there is an unlimited number of application fields. It is a component, to be used together with other components.
There are use cases that can be solved better today with vector search and LLMs, sometimes combining keyword search and vector search into hybrid search exceeds each of them, but in many instances keyword search is still the best solution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keyword search is exact, lossless, works with any language, with new, out-of-vocabulary terms, is always up-to-date, doesn’t require huge existing corpora for expensive and time-consuming learning of embeddings or LLMs which are prone to become outdated, it is very fast, with better scaling, better latency, and throughput, has much less infrastructure requirements, and consequently, is much more energy-efficient&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You should know all your tools, and what their benefits and drawbacks are for your specific use case. Most of the time, technologies are not competing, but complementing each other.
Maintain a toolbox, and choose the best tool for your task at hand. https://seekstorm.com/blog/vector-search-vs-keyword-search1/&lt;/p&gt;

&lt;p&gt;Even today, with a mature technology like keyword search which has been there for decades, &lt;strong&gt;innovation in architecture and algorithms enables performance improvements by a order of magnitude&lt;/strong&gt; and make it fit for the next decades to come.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keyword search is here to stay&lt;/strong&gt;, and whenever performance is important, SeekStorm might be one of the best options for you.&lt;/p&gt;

</description>
        <pubDate>Sat, 02 Dec 2023 00:00:00 +0000</pubDate>
        <link>https://seekstorm.com/blog/sneak-peek-seekstorm-rust/</link>
        <guid isPermaLink="true">https://seekstorm.com/blog/sneak-peek-seekstorm-rust/</guid>
        
        
        <category>search</category>
        
        <category>performance</category>
        
        <category>rust</category>
        
        <category>oss</category>
        
      </item>
    
  </channel>
</rss>
