# WarpSearch > The WarpSearch documentation as one Markdown file. https://warpsearch.io/llms.txt lists the same pages, one line each. --- Source: https://warpsearch.io/docs/agents # Guide for AI agents This page addresses an AI agent. If you are a person, start with the [Quickstart](quickstart.md). ## What WarpSearch is WarpSearch is a serverless hybrid search service: full-text (BM25), vector, geo and faceted search over JSON documents, plus analytics (facets, metrics, histograms). Data lives in collections: index JSON documents into one, then search it. Query it in SQL, Elasticsearch/OpenSearch Query DSL, Solr, Lucene or the native language, or point an existing Elasticsearch, OpenSearch or Solr client at it. ## Step 1: no API key yet Connect to the MCP server `https://api.warpsearch.io/mcp` (streamable HTTP) **without** an `Authorization` header. It then offers only two tools, which sign your user up. 1. Call `register` with the email address your user gave you for this. Never guess an address. It must be a work address at your user's organization's own domain: free and personal mailbox providers (gmail.com, outlook.com and the like) are refused with `personal_email`, so ask for a work address instead. Optional: `name`, `agent` (who you are, shown to your user) and `role`: `admin` (the default), `editor` (can also create collections and change schemas), `writer` (index documents) or `viewer` (search and read). Ask for `editor` or higher to create collections. 2. It returns a `user_code` and a `claim_token`. Show the code to your user. Keep the token to yourself: whoever holds it receives the key. 3. Your user opens the email from WarpSearch, follows its link, checks that the page shows your `user_code`, chooses the organization and your role, and approves. 4. When they say they are done, call `claim_registration` with the `claim_token`. While it answers `pending`, ask them to finish and call again, no more than every 10 seconds. `approved` carries the `api_key`, shown **once**: store it securely. 5. Reconnect with `Authorization: Bearer `. Requests expire after an hour, and each address gets at most 3 sign-up emails an hour. If `denied` comes back, do not register again unless your user asks you to. Your user can delete the key under **API keys** in the [console](/console/). MCP client configuration with a key: ```json { "mcpServers": { "warpsearch": { "type": "http", "url": "https://api.warpsearch.io/mcp", "headers": { "Authorization": "Bearer ws_..." } } } } ``` Claude Code: `claude mcp add --transport http warpsearch https://api.warpsearch.io/mcp --header "Authorization: Bearer ws_..."` ## Step 2: you have an API key Keys start with `ws_`. Every request to `https://api.warpsearch.io` needs one; nothing is served anonymously except the MCP guide, server card and registration tools. Send it as `Authorization: Bearer ` (`X-API-Key: ` also works). Check it first: ```bash curl -H "Authorization: Bearer $WARPSEARCH_API_KEY" https://api.warpsearch.io/v1/auth/me ``` It returns your roles, permissions and rate limits. Over MCP, `whoami` and `list_collections` do the same. Then pick the page for what you want to do: | I want to ... | Read | |---|---| | Create a collection, or describe or change one | [Collections](collections.md) | | Load documents (batches, partial failures, large loads) | [Ingesting documents](ingesting-documents.md) | | Know when a write is searchable, or retry safely | [Writes, visibility and durability](consistency-and-durability.md) | | Search by keyword, with filters, sorting and paging | [Searching](searching.md) | | Show matching snippets, or which query words a hit matched | [Highlighting](highlighting.md): `highlight` on `POST /v1/search/{c}` or the MCP `search` tool, with `summary` for match summaries | | Search by vector, or combine keyword and vector | [Vector search](vector-search.md), [Hybrid search](hybrid-search.md) | | Group results, count, sum, histograms | [Facets and aggregations](facets-and-aggregations.md) | | Search by location or area | [Geo search](geo-search.md) | | Search several collections at once | [Multi-collection queries](multi-collection-queries.md) | | Query in SQL, Lucene, PPL or Grafana syntax | [Query languages](query-languages.md), [SQL](sql.md) | | Move an Elasticsearch, OpenSearch or Solr client over | [Elasticsearch](compat-elasticsearch.md) (`/compat/es`: `_bulk`, `_search`, `knn`, `_refresh`), [OpenSearch](compat-opensearch.md), [Solr](compat-solr.md), [turbopuffer](compat-turbopuffer.md) | | Define fields, analyzers and languages | [Schemas and field types](schemas-and-fields.md), [Languages and text analysis](text-analysis.md) | | Walk relationships between documents | [Graph search](graph.md) | | Register queries and match documents against them | [Match API](match-api.md) | | Load or benchmark a large dataset | [Ingesting documents](ingesting-documents.md#batching-and-throughput), then [Limits and errors](limits-and-errors.md) | | Understand an error or a limit | [Limits and errors](limits-and-errors.md) | | Call the REST API directly | [REST API reference](api-reference.md) | The REST API is `https://api.warpsearch.io/v1`; the compatible endpoints are `https://api.warpsearch.io/compat/es`, `/compat/opensearch`, `/compat/solr` and `/compat/turbopuffer`. ## Step 3: machine-readable files - [/llms.txt](/llms.txt): index of the docs, one line per page. - [/llms-full.txt](/llms-full.txt): the whole docs as one Markdown file. - [/openapi.yaml](/openapi.yaml): OpenAPI 3.1 description of the REST API, no key needed. - [MCP Server Card](https://api.warpsearch.io/mcp/server-card), and `GET https://api.warpsearch.io/mcp` without `Accept: text/event-stream`: a short version of this guide. - [/.well-known/ai-catalog.json](/.well-known/ai-catalog.json) and [/.well-known/api-catalog](/.well-known/api-catalog): catalogs of the above. - Every docs page is Markdown at `/docs/.md`. --- Source: https://warpsearch.io/docs/ # WarpSearch documentation WarpSearch is serverless hybrid search that is fast and costs a fraction of what a cluster does: keyword precision and vector understanding in a single query, with no clusters to run. You define collections with a native schema and search them through the WarpSearch REST API or the MCP server for AI agents. It is also a drop-in replacement for Elasticsearch, OpenSearch, Solr and turbopuffer, so existing clients and queries keep working. - **Fast.** Keyword search answers in 1 to 6 ms at the median, and vector search over 10M vectors in about 6 ms at 0.96 recall. Keyword, vector and hybrid run on one index, so there is no second system to fan out to. - **Cheap.** You pay per GB stored, per GB written and per request. An idle index costs only its storage, there are no nodes or replicas to size, and there is a free tier. See [pricing and cost control](pricing.md). ## Get started - [Quickstart](quickstart.md): create an account, load documents and run your first query. - [Set up with your coding agent](agent-quickstart.md) ## Concepts - [Core concepts](concepts.md) - [Collections](collections.md) - [Schemas and field types](schemas-and-fields.md) - [Writes, visibility and durability](consistency-and-durability.md) - [Languages and text analysis](text-analysis.md): [Snowball stemming](snowball-stemming.md), [more languages](more-languages.md), [Arabic](arabic.md), [Hebrew](hebrew.md), [Chinese, Japanese and Korean](cjk.md), [multilingual text](icu.md) and [language detection](language-detection.md); [synonym filters](synonym-filters.md), [autocomplete with n-grams](autocomplete.md), [phonetic matching](phonetic-matching.md) and the [tokenizers and filters](analysis-components.md) for your own analyzers; analyzers for [source code](source-code.md), [phone numbers](phone-numbers.md) and [command lines](command-line-search.md), with [suffix search](suffix-search.md) and [substring search](substring-search.md) ## Guides - [Ingesting documents](ingesting-documents.md) - [Searching](searching.md) - [Multi-collection queries](multi-collection-queries.md): combine, filter, sort and join data from several collections. - [Match API (reverse search)](match-api.md): register queries once and find which ones match each document, also called percolation. - [Facets and aggregations](facets-and-aggregations.md) - [Geo search](geo-search.md), with [geo points and queries](geo-points-and-queries.md), [distance sorting and nearest](geo-distance-and-nearest.md), [geo aggregations](geo-aggregations.md) and [geo shapes](geo-shapes.md) - [Vector search](vector-search.md), with [dimensions and storage trade-offs](matryoshka-and-dimensions.md) and [multi-vector fields](multi-vector-fields.md) - [Hybrid search](hybrid-search.md) - [Graph search](graph.md) - [Guide for AI agents](agents.md): connect an agent over MCP. ## Query languages - [Overview](query-languages.md): sending queries, translation, and [moving from Elasticsearch, OpenSearch or Solr](query-languages.md#moving-from-elasticsearch-opensearch-or-solr). - [SQL and PostgreSQL](sql.md), including full-text search and pgvector. - [PPL](ppl.md): pipe queries for log analysis, transformations, aggregation and joins. - [Elasticsearch](compat-elasticsearch.md) - [OpenSearch](compat-opensearch.md) - [Solr](compat-solr.md) - [LogQL](compat-loki-logql.md) - [turbopuffer compatibility](compat-turbopuffer.md) ## Integrations - [Overview](integrations.md) - [Umbraco](integration-umbraco.md) - [WooCommerce](integration-woocommerce.md) - [Magento](integration-magento.md) - [Shopify](integration-shopify.md) - [BigCommerce](integration-bigcommerce.md) ## Management - [API keys, roles and rate limits](access-control.md) - [Pricing and cost control](pricing.md) ## Reference - [REST API reference](api-reference.md) - [Limits and errors](limits-and-errors.md) - [FAQ](faq.md) --- Source: https://warpsearch.io/docs/quickstart # Quickstart Create an account, load a few documents and run keyword, vector and hybrid queries, first in the console and then over the API. ## 1. Create an account Sign up in the [management console](/console/). Every account gets 1 GB of indexed data in one collection free, permanently. A coding agent can do the setup for you: add the WarpSearch MCP server to its configuration and ask it to set up search for your data. [Set up with your coding agent](agent-quickstart.md) walks through it. ```json { "mcpServers": { "warpsearch": { "url": "https://api.warpsearch.io/mcp" } } } ``` Without a key, the agent can only register you. You approve its request from an email, choose the organization and the role it gets (editor or admin lets it create collections), and the agent receives an API key. Nothing is created until you approve, and you can delete the agent's key under **API keys** at any time. If you already have a key, send it with the connection instead: `"headers": { "Authorization": "Bearer ws_..." }`. ## 2. Create a collection and load documents In the console, open **Collections** and create one (editors and admins can; the free plan includes one collection). Then open its **Ingest** tab and paste or upload a JSON array or NDJSON. To load documents from your own code, create an API key with the writer role under **API keys**. ## 3. Search Run a query from the collection's page in the console. If you already use an Elasticsearch, OpenSearch or Solr client, you can keep it; see [Moving from Elasticsearch, OpenSearch or Solr](query-languages.md#moving-from-elasticsearch-opensearch-or-solr). ## 4. Do the same over the API Everything in the console is also available over HTTP. Create an API key under **API keys** (the writer role can load documents and search; creating collections needs editor), then export it: ```bash export WARPSEARCH_API_KEY=ws_... ``` The examples use 4-dimensional vectors so they stay readable; real embeddings have hundreds or thousands of dimensions. WarpSearch does not compute embeddings, so you send the vectors yourself. See [Vector search](vector-search.md). ### Create a collection with a vector field ::: tabs API === WarpSearch ```bash curl -X PUT https://api.warpsearch.io/v1/collections/products \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "schema": { "fields": { "title": { "parent": "_t" }, "category": "string", "embedding": { "type": "vector", "dims": 4, "metric": "cosine" } } } }' ``` `"parent": "_t"` gives `title` the built-in text analysis (word splitting, case and accent folding, English stemming). The schema can be JSON or YAML. === Elasticsearch For Elasticsearch clients and tools: ```bash curl -X PUT https://api.warpsearch.io/compat/es/products \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mappings": { "properties": { "title": { "type": "text" }, "category": { "type": "keyword" }, "embedding": { "type": "dense_vector", "dims": 4, "similarity": "cosine" } } } }' ``` === OpenSearch For OpenSearch clients and tools: ```bash curl -X PUT https://api.warpsearch.io/compat/opensearch/products \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "settings": { "index": { "knn": true } }, "mappings": { "properties": { "title": { "type": "text" }, "category": { "type": "keyword" }, "embedding": { "type": "knn_vector", "dimension": 4, "method": { "name": "hnsw", "space_type": "cosinesimil" } } } } }' ``` ::: Collection names start with a lowercase letter and contain only lowercase letters, digits and `_`. See [Collections](collections.md) and [Schemas and field types](schemas-and-fields.md). ### Ingest documents with vectors Send NDJSON (one document per line) or a JSON array. Add `commit=true` to make the documents searchable before the request returns. ::: tabs API === WarpSearch ```bash curl -X POST "https://api.warpsearch.io/v1/collections/products/documents?commit=true" \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/x-ndjson" \ --data-binary @- <<'DOCS' {"id":"1","title":"Espresso machine with milk frother","category":"kitchen","embedding":[0.9,0.1,0.0,0.1]} {"id":"2","title":"Burr coffee grinder","category":"kitchen","embedding":[0.8,0.2,0.1,0.0]} {"id":"3","title":"Trail running shoes","category":"outdoor","embedding":[0.0,0.1,0.9,0.2]} DOCS ``` The response reports `indexed` and `failed` counts. === Elasticsearch The `_bulk` API, for Elasticsearch and OpenSearch clients (use `/compat/opensearch` for the latter). `refresh=true` makes the documents searchable before the call returns: ```bash curl -X POST "https://api.warpsearch.io/compat/es/products/_bulk?refresh=true" \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/x-ndjson" \ --data-binary @- <<'DOCS' {"index":{"_id":"1"}} {"title":"Espresso machine with milk frother","category":"kitchen","embedding":[0.9,0.1,0.0,0.1]} {"index":{"_id":"2"}} {"title":"Burr coffee grinder","category":"kitchen","embedding":[0.8,0.2,0.1,0.0]} {"index":{"_id":"3"}} {"title":"Trail running shoes","category":"outdoor","embedding":[0.0,0.1,0.9,0.2]} DOCS ``` ::: See [Ingesting documents](ingesting-documents.md). ### Keyword search A search request's `language` is `text` by default (the words a person typed, matched forgivingly); `lucene`, `sql`, `es` (Elasticsearch Query DSL), `solr` and others are a field away. `limit`, `offset`, `fields`, `filters`, `sort` and `facets` work the same in all of them. See [Searching](searching.md) and [Query languages](query-languages.md). ::: tabs API === WarpSearch ```bash curl -X POST https://api.warpsearch.io/v1/search/products \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "language": "lucene", "query": "title:coffee", "limit": 10 }' ``` === Elasticsearch ```bash curl -X POST https://api.warpsearch.io/compat/es/products/_search \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "query": { "match": { "title": "coffee" } }, "size": 10 }' ``` === Solr ```bash curl "https://api.warpsearch.io/compat/solr/products/select?q=title:coffee&rows=10" \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" ``` ::: ### Vector search Pass a query vector computed with the same model as your documents. On the WarpSearch API, write it as a `knn` section with `"language": "es"` (`query` then holds an Elasticsearch search body), or in SQL with `ORDER BY` on the `<=>` distance operator (`"language": "pgsql"`). `filters` restrict the matches. ::: tabs API === WarpSearch ```bash curl -X POST https://api.warpsearch.io/v1/search/products \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "language": "es", "query": { "knn": { "field": "embedding", "query_vector": [0.85, 0.15, 0.05, 0.05], "k": 10 } }, "filters": [ { "term": { "category": "kitchen" } } ], "limit": 10 }' ``` The same search in SQL: ```bash curl -X POST https://api.warpsearch.io/v1/search/products \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ --data-binary @- <<'JSON' {"language": "pgsql", "query": "SELECT id, title FROM products WHERE category = 'kitchen' ORDER BY embedding <=> '[0.85,0.15,0.05,0.05]' LIMIT 10"} JSON ``` === Elasticsearch ```bash curl -X POST https://api.warpsearch.io/compat/es/products/_search \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "knn": { "field": "embedding", "query_vector": [0.85, 0.15, 0.05, 0.05], "k": 10, "filter": { "term": { "category": "kitchen" } } }, "size": 10 }' ``` === OpenSearch ```bash curl -X POST https://api.warpsearch.io/compat/opensearch/products/_search \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "query": { "knn": { "embedding": { "vector": [0.85, 0.15, 0.05, 0.05], "k": 10, "filter": { "term": { "category": "kitchen" } } } } }, "size": 10 }' ``` ::: ### Hybrid search To combine a text query and a vector search in one request, put a `knn` section beside `query`: ::: tabs API === WarpSearch ```bash curl -X POST https://api.warpsearch.io/v1/search/products \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "language": "es", "query": { "query": { "match": { "title": "coffee" } }, "knn": { "field": "embedding", "query_vector": [0.85, 0.15, 0.05, 0.05], "k": 10 } }, "limit": 10 }' ``` === Elasticsearch ```bash curl -X POST https://api.warpsearch.io/compat/es/products/_search \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "query": { "match": { "title": "coffee" } }, "knn": { "field": "embedding", "query_vector": [0.85, 0.15, 0.05, 0.05], "k": 10 }, "size": 10 }' ``` ::: A document matches when either part does, and its score is the sum of both scores. Each part can carry its own `boost`, and a `filter` inside `knn` restricts the vector candidates. For this and for rank fusion (RRF), see [Hybrid search](hybrid-search.md). ## Next steps - [Concepts](concepts.md): how collections, documents and fields fit together. - [Searching](searching.md) and [Facets and aggregations](facets-and-aggregations.md). - [Vector search](vector-search.md) and [Hybrid search](hybrid-search.md). - [Access control](access-control.md): API keys and roles. - [Limits and errors](limits-and-errors.md) and the [REST API reference](api-reference.md). - Coming from another engine? See [Moving from Elasticsearch, OpenSearch or Solr](query-languages.md#moving-from-elasticsearch-opensearch-or-solr). --- Source: https://warpsearch.io/docs/agent-quickstart # Set up with your coding agent Your coding agent can do the whole setup: sign you up, create a collection, load your documents and add search to your app. You add one MCP server to your tool and approve one email, without copying a key or visiting the console first. ## 1. Add the MCP server WarpSearch's MCP server is `https://api.warpsearch.io/mcp` (streamable HTTP). Add it without any credentials; the agent gets a key in step 2. ::: tabs Coding tool === Claude Code Run in your terminal: ```bash claude mcp add --transport http warpsearch https://api.warpsearch.io/mcp ``` Check it with `claude mcp list`, or `/mcp` inside a session. === Codex Run in your terminal: ```bash codex mcp add warpsearch --url https://api.warpsearch.io/mcp ``` Check it with `codex mcp list`. === Gemini CLI Run in your terminal: ```bash gemini mcp add --transport http warpsearch https://api.warpsearch.io/mcp ``` Check it with `gemini mcp list`, or `/mcp` inside a session. === VS Code Add this to `.vscode/mcp.json` in your project: ```json { "servers": { "warpsearch": { "type": "http", "url": "https://api.warpsearch.io/mcp" } } } ``` Start the server from the file, then use GitHub Copilot Chat in **Agent** mode. ::: Any other tool that supports remote (streamable HTTP) MCP servers works the same way: point it at the URL. The console [Overview](https://warpsearch.io/console/) shows these commands with a copy button. ## 2. Ask for access and approve it Start your tool and describe what you want, for example: ```text Set up WarpSearch search for the help-center articles in ./content ``` Without a key, the server offers the agent only two tools, which sign you up. The agent asks which email address to register (it does not use your account's address without asking), sends the request, and shows you a short code. Claude Code asked to set up WarpSearch for RAG. It asks for an email address, then shows a confirmation code and the steps to approve access. WarpSearch emails that address. The email names the agent that asked and repeats the code. 1. Check that the code in the email is the one your agent showed. If it is not, stop. 2. Choose **Create account and approve**. A new address creates the account first, so you confirm the email and choose a password. 3. Choose the organization and the role the agent gets, then approve. `viewer` can search, `writer` can also load data, `editor` can also create collections and change schemas, and `admin` can also delete collections. To create the collection the agent needs at least `editor`; you can lower the role it asked for. The WarpSearch email titled "Your AI agent asked to create a WarpSearch account for you", with the confirmation code and a Create account and approve button. Tell the agent you have approved. It collects an API key for that role (shown to it only once), reconnects with it and gets the search and indexing tools. The request expires after 60 minutes, and each address can receive at most 3 sign-up emails an hour. ## 3. Create a collection A collection holds your documents and their schema. The agent reads a sample of your data and creates one with `create_collection`. Ask it to show you the schema first if you want to review it: ```text Look at the articles in ./content and propose a WarpSearch collection for them. Show me the fields before you create it. ``` What the agent decides, and what to check: | Choice | What to check | |---|---| | Name | Lowercase letters, digits and `_`, starting with a letter: `help_center`, not `help-center`. | | Class | `knowledge` for RAG chunks and embeddings, `search` (the default) for site, catalog and app search, `stream` for logs and events. See [Collection classes](collections.md#collection-classes). | | Fields | `text` for anything people search by words (titles, bodies), `string` for exact values you filter or facet on (category, language, status), numbers and dates for ranges and sorting, and `vector` with `dims` and `metric` for embeddings. A schema is optional: fields named with a type suffix such as `title_t` or `category_s` are typed by their name. See [Schemas and field types](schemas-and-fields.md). | A typical schema for help-center articles, passed as the `schema` argument of `create_collection`: ::: tabs API === WarpSearch ```json { "fields": { "title": {"parent": "_t"}, "body": {"parent": "_t"}, "category": "string", "updated_at": "date", "embedding": {"type": "vector", "dims": 1024, "metric": "cosine"} } } ``` === Elasticsearch The same fields as an Elasticsearch mapping, for a collection created through `PUT /compat/es/{index}` with an Elasticsearch client: ```json { "properties": { "title": {"type": "text"}, "body": {"type": "text"}, "category": {"type": "keyword"}, "updated_at": {"type": "date"}, "embedding": {"type": "dense_vector", "dims": 1024, "similarity": "cosine"} } } ``` ::: You can add fields later, but a change that would break documents already stored (a new type, different vector dimensions, a different analyzer) is refused with `409 incompatible_schema`, so settle the types before a large load. Creating collections needs the `editor` role, and your plan sets how many you can have. ## 4. Load your documents The agent turns your data into flat JSON documents, each with an `id`, and indexes them: ```text Index every article into help_center. Use the file path as the id, and compute embeddings with the model our app already uses. ``` How it goes about it: - A small sample, such as a few hundred documents for a first try, goes straight through the `index_documents` tool. - A full load works better as a script the agent writes against the REST API (`POST /v1/collections/{c}/documents`, JSON or NDJSON), so your documents do not pass through the agent's context. Ask it to read the key from an environment variable such as `WARPSEARCH_API_KEY`. If you already have an ingestion pipeline, ask it to add WarpSearch as a destination there instead. - It sends documents in batches, commits on the last batch only, reads each response and retries just the documents that failed. A `413` means a batch is over your plan's limit, and the agent splits it. - Check [nested API availability](schemas-and-fields.md#nested-documents) before choosing a nested schema. Flattening loses same-child relationships in arrays of objects. Posting an existing `id` replaces the whole document. - WarpSearch does not compute embeddings. The agent calls your embedding model and sends the vectors, with exactly the `dims` the collection declares. See [Ingesting documents](ingesting-documents.md) for the options and the error codes. ## 5. Search and wire it into your app Once the documents are committed, the agent can query them with the `search` and `count` tools. They mirror `POST /v1/search/{c}`: a query in the `language` the agent knows best (SQL, Elasticsearch Query DSL, Solr or Lucene), plus `filters`, `facets`, `sort` and `limit`. ```text Run the 20 most common questions from our support tickets against help_center and show me the top 3 results for each. Then add a /search endpoint to our app. ``` What to expect: - The agent runs real questions, checks hit counts, and adjusts fields, filters or the schema where results are wrong. `translate_query` shows how WarpSearch runs any query. - For RAG it combines a keyword query with a `knn` section on the embedding field (with `"language": "es"`), so exact terms like error codes and part numbers still match. See [Hybrid search](hybrid-search.md). - For a search results page it adds `highlight` to the same `search` call to get snippets with the matching words marked. With `"language": "text"` and `"summary": true`, each snippet also says which of the user's words the hit matched (`match_level`, `matched_words`). See [Highlighting](highlighting.md#match-summaries). - Your app calls `POST /v1/search/{c}` from your backend with a key kept in configuration, not in code. Give your app a `viewer` key of its own (create one under **API keys** in the console) rather than reusing the agent's. If your app already uses an Elasticsearch, OpenSearch or Solr client, it can keep it and change only the endpoint; see [Moving from Elasticsearch, OpenSearch or Solr](query-languages.md#moving-from-elasticsearch-opensearch-or-solr). See [Searching](searching.md) for the request and response. ## Keep control - You decide the scope. Ask for only the schema, only a sample load, or only the app wiring, and the agent stops there. - The key belongs to the organization and role you approved. Delete it any time under **API keys** in the console. - Ask the agent to keep the key out of code, logs and commits. - The agent's key expires after 24 hours, or after one hour without use. - If you refuse the request, the agent is told it was denied and does not ask again unless you tell it to. ## Where to go next - [Quickstart](quickstart.md): the same steps by hand, with the API. - [Guide for AI agents](agents.md): what your agent reads, including every MCP tool. - [Vector search](vector-search.md) and [Hybrid search](hybrid-search.md), the building blocks of RAG. - [Facets and aggregations](facets-and-aggregations.md), for filters and counts in your search UI. --- Source: https://warpsearch.io/docs/migrate-from-turbopuffer # Migrate from turbopuffer WarpSearch serves the turbopuffer HTTP API at `https://api.warpsearch.io/compat/turbopuffer`, so the official turbopuffer SDKs for Python, TypeScript, Go, Java and Ruby run against it once you change the base URL and the API key. A turbopuffer namespace becomes a WarpSearch collection. This page walks through a move: connect, check what your code uses, copy the data, and trial it. The [turbopuffer compatibility](compat-turbopuffer.md) page has the full reference. ## 1. Point the SDK at WarpSearch Create an API key in the [management console](/console/), then change two settings and remove the region. Every SDK refuses to start when a region is set and the base URL has no `{region}` placeholder. ```bash export TURBOPUFFER_BASE_URL=https://api.warpsearch.io/compat/turbopuffer export TURBOPUFFER_API_KEY=ws_... unset TURBOPUFFER_REGION ``` Or in code: ```python from turbopuffer import Turbopuffer warp = Turbopuffer( base_url="https://api.warpsearch.io/compat/turbopuffer", api_key="ws_...", ) ``` The setting names for each SDK are in the [Connect](compat-turbopuffer.md#connect) table. Creating a namespace needs a key with the `editor` or `admin` role; writes need `writer` and queries need `viewer`. ## 2. Check what works and what answers 501 | Area | On WarpSearch | |---|---| | Writes | `upsert_rows`, `upsert_columns`, `deletes`, `distance_metric`, `schema`, `create_namespace`, `return_affected_ids` | | Queries | Vector `ANN` and exact `kNN`, BM25 full text, ordering by attributes, filters, `aggregate_by`, multi-query with RRF. See [Queries](compat-turbopuffer.md#queries) | | Namespaces | Write, query, delete, list, metadata, schema, `hint_cache_warm` | | `501`, not implemented yet | `patch_rows`, `patch_columns`, `patch_by_filter`, `delete_by_filter`, conditional writes (`upsert_condition`, `patch_condition`, `delete_condition`), `encryption`, `copy_from_namespace`, `branch_from_namespace`, `explain_query`, `_debug/recall`, `PATCH` on namespace metadata | | `501` in queries | The `Attribute`, `Saturate`, `Decay` and `Dist` rank expressions, `SparseKNN`, `Embed` in `rank_by`, `compute_attributes` (including `Highlight`), `rerank_by` with a model, `IGlob` and `NotIGlob`, and some `Glob` and `limit.per` forms | | Not supported | Sparse vectors, multi-vector `late_interaction`, `bytes`, `[N]i8` and `embed`. WarpSearch does not create embeddings; send your own vectors | A write that contains any `501` feature is rejected and writes nothing, even if it also contains upserts. `501` responses carry `x-should-retry: false`, so the SDK raises at once. Search your code for the features above before you start; each one needs a change, such as a full upsert in place of a patch. ## 3. Copy a namespace There is no server-side copy between turbopuffer and WarpSearch. Page through the turbopuffer namespace ordered by `id`, and upsert each page into WarpSearch. Run this with your turbopuffer client configured as it is today, and a second client pointed at WarpSearch: ```python from turbopuffer import Turbopuffer source = Turbopuffer(region="gcp-us-central1", api_key="tpuf_...") # your turbopuffer account warp = Turbopuffer(base_url="https://api.warpsearch.io/compat/turbopuffer", api_key="ws_...") src = source.namespace("docs") dst = warp.namespace("docs") attributes = ["vector", "text", "category"] # every attribute you want to keep page_size = 1000 # keep within turbopuffer's top_k limit last_id = None while True: query = {"rank_by": ("id", "asc"), "top_k": page_size, "include_attributes": attributes} if last_id is not None: query["filters"] = ("id", "Gt", last_id) page = src.query(**query) if not page.rows: break dst.write( upsert_rows=[row.to_dict() for row in page.rows], distance_metric="cosine_distance", # the metric the namespace uses on turbopuffer schema={"text": {"type": "string", "full_text_search": True}}, ) last_id = page.rows[-1].id ``` - **Schema first.** Send the same `schema` you use on turbopuffer with the first write, including `full_text_search` on text attributes. Types are otherwise inferred from the first non-null value. Changing an attribute's options later (for example turning on `full_text_search`) answers `501`, so set them up front. - **Vectors.** A column named `vector` is a vector automatically. Any other vector attribute needs an `[N]f32` type or `ann: true` in `schema`. - **Attribute names.** Letters, digits, `_`, `.` and `@`, starting with a letter or `_`. Rename others before you write them, or the write fails with `400`. - **Namespace names.** Names that are not valid collection names (uppercase, `-`, `.`) work through the turbopuffer API unchanged and are stored under a derived `tp_...` collection name. - **Request size.** Plan limits on documents and bytes per request apply. On `413 request_too_large`, write smaller pages. See [Limits and errors](limits-and-errors.md). - **Check the count.** `GET /v2/namespaces/{namespace}/metadata` reports `approx_row_count`, refreshed about once a minute. Compare it with the source namespace after the copy. Writes are committed before the response returns, so the next query sees them. ## 4. Trial checklist 1. **Run your test suite** against WarpSearch with the new base URL. Log every `501` and `400`; that list is your migration work. 2. **Compare results.** Vector distances are the same as turbopuffer's. BM25 matching rows, `$dist` and ordering can differ (different tokenizer, stop words kept, English-only KStem stemming). 3. **Check ordering by attributes.** Documents without a value sort last in both directions; turbopuffer puts them first when ascending. 4. **Check multi-query.** Without `rerank_by`, each subquery runs separately, not on one snapshot. 5. **Plan for idle collections.** A collection that has been idle can answer `503 warming_up` with a `Retry-After` header while it loads. Retry on that code, call `hint_cache_warm` ahead of traffic, or use keep-warm. See [Idle collections and cold starts](collections.md#idle-collections-and-cold-starts). 6. **Read usage in the console.** The `billing` fields in responses are always zero; WarpSearch bills by [its own plans](pricing.md). 7. **Check the cost model.** Compare current plans using your measured query volume, storage, returned data and keep-warm usage. A single index-size threshold does not establish which service costs less. See [Pricing](pricing.md). 8. **Cut over.** Switch the environment variables in production, and keep the turbopuffer namespace until you are satisfied. --- Source: https://warpsearch.io/docs/migrate-from-elasticsearch # Migrate from Elasticsearch or OpenSearch WarpSearch serves Elasticsearch- and OpenSearch-compatible REST APIs, so most applications move by changing the base URL and the credential. This page walks through a move: check what your application uses, connect, load the data, and trial it. The [Elasticsearch](compat-elasticsearch.md) and [OpenSearch](compat-opensearch.md) pages have the full reference. ## 1. Pre-flight check Before you copy any data, check whether your application depends on something WarpSearch does not support: | Feature | On WarpSearch | |---|---| | Kibana, OpenSearch Dashboards | Unsupported. Grafana data sources work; an ES\|QL subset is served at `/compat/es/_query` | | Nested and parent/child documents | See [nested document behavior and REST API limitations](schemas-and-fields.md#nested-documents). Elasticsearch `join` fields remain unsupported | | Scripts (Painless), `runtime_mappings`, `script_fields` | **Not supported** | | Paging | Field-sort `search_after`, native cursors, Solr `cursorMark` and emulated scroll work. No point-in-time snapshot or slices. See [Paging](searching.md#paging) | | Index resolution | Index lists, patterns, exclusions and `_all` work. No index aliases. Data streams map to one collection without rollover | | Index templates and ILM | Setup calls are acknowledged but definitions are not stored or applied. Snapshots remain unsupported | | Partial updates and query-based writes | Native PATCH, `_update` and bulk partial updates work with concurrency restrictions. Update/delete by query, `_reindex` and ingest pipelines remain unsupported | | Dynamic mapping | Supported on Elasticsearch/OpenSearch-created collections, including strict/disabled modes and dynamic templates. Native schemas still require field definitions or suffixes | | Aggregations | Pipeline aggregations work; composite, significant terms and rare terms have availability and input restrictions. See [Aggregations](compat-elasticsearch.md#aggregations) | | `semantic`, `sparse_vector`, `neural` and `neural_sparse` queries | **Not supported.** Compute embeddings in your application and send the vectors | | HTTP Basic authentication | Key as password with username `apikey` or empty; arbitrary usernames are rejected | | Relevance scores | **Not identical.** Analysis differences and documented approximations can change matching documents, scores and ranking | Full lists: [Elasticsearch, not supported](compat-elasticsearch.md#not-supported) and [OpenSearch, not supported](compat-opensearch.md#not-supported). Also check your mappings. `join`, `flattened`, `completion`, `binary` and `ip_range` are rejected. Field aliases and numeric/date range mappings work. For nested fields, see the [REST API limitations](schemas-and-fields.md#nested-documents). Field names with `@` or `.` are mapped for you (`@timestamp` is stored as `timestamp`), and you keep using your own names in queries and responses. See [Mappings](compat-elasticsearch.md#mappings). ## 2. Connect your client Create an API key in the [management console](/console/). Send it as `Authorization: Bearer`, `Authorization: ApiKey` or `X-API-Key`. | Product | Base URL | |---|---| | Elasticsearch clients | `https://api.warpsearch.io/compat/es` | | OpenSearch clients | `https://api.warpsearch.io/compat/opensearch` | ```diff - es = Elasticsearch("https://my-cluster.example.com:9200", basic_auth=("user", "pass")) + es = Elasticsearch("https://api.warpsearch.io/compat/es", api_key="ws_...") ``` ```python from opensearchpy import OpenSearch client = OpenSearch( hosts=[{"host": "api.warpsearch.io", "port": 443, "url_prefix": "compat/opensearch"}], use_ssl=True, headers={"Authorization": "Bearer ws_..."}, ) ``` Settings for every official client, Logstash, Beats, Fluent Bit, Vector and Grafana are in the [Elasticsearch](compat-elasticsearch.md#base-url) and [OpenSearch](compat-opensearch.md#connect) tables. The Java API client sends `typed_keys=true`, which WarpSearch does not honor, so use the low-level REST client or raw JSON for aggregations. ## 3. Replay your queries Create an index with your mapping and a sample of your data, then run a day of production queries, or your test suite, against it. Log every `Warning: 299` header (an approximation that still answered) and every `400 unsupported_feature`. That list is your migration work. ## 4. Load your data There is no `_reindex` from another cluster. Read from your current cluster as you do today (scroll, a snapshot reader, or your source database) and write into WarpSearch through `_bulk`. 1. **Create the index first,** with your mapping and analysis settings: `PUT /{index}` on the compatible endpoint. Explicit mappings avoid unwanted inference; dynamic mapping is also supported. 2. **Bulk load.** Keep your document ids. Include your existing vectors; WarpSearch does not create embeddings. 3. **Refresh and force merge** after a large load. `_forcemerge` (editor role) also builds the approximate vector indexes. ```python from elasticsearch import Elasticsearch, helpers source = Elasticsearch("https://my-cluster.example.com:9200", basic_auth=("user", "pass")) warp = Elasticsearch("https://api.warpsearch.io/compat/es", api_key="ws_...") mapping = source.indices.get_mapping(index="books")["books"]["mappings"] warp.indices.create(index="books", mappings=mapping) actions = ( {"_index": "books", "_id": hit["_id"], "_source": hit["_source"]} for hit in helpers.scan(source, index="books", query={"query": {"match_all": {}}}) ) for ok, item in helpers.streaming_bulk(warp, actions, chunk_size=1000, max_retries=5, raise_on_error=False): if not ok: print(item) warp.indices.refresh(index="books") warp.indices.forcemerge(index="books") ``` `helpers.scan` uses scroll on your current cluster, which supports it; WarpSearch only receives `_bulk` requests. How `_bulk` behaves: - Overload is reported per item as `429`, so clients can retry just those items. - `create` checks for an existing id and returns `409` when found; concurrent creates can race. - Atomic version/sequence-number concurrency is unsupported; partial updates reject `if_seq_no`. - Without `refresh`, visibility depends on the collection’s default durability and commit interval. See [Write semantics](compat-elasticsearch.md#write-semantics). Shippers such as Logstash and Beats can also write through `_bulk`; turn off their index template, ILM and ingest pipeline steps and create the collection yourself. ## 5. Trial checklist 1. **Unsupported features:** the replay in step 3 shows no `400 unsupported_feature`, or each one has a workaround. 2. **Warnings reviewed:** every `Warning: 299` from the replay is acceptable for your application. 3. **Counts match:** `_count` on each index matches your current cluster after the load. 4. **Results compared:** send the same queries to both and compare top results by rank order, not by `_score`. 5. **Responses parse:** `_source` dates come back as epoch milliseconds and multi-valued fields as lists; there is no `_shards`, `_version` or `_seq_no`. See [Behavior differences](compat-elasticsearch.md#behavior-differences). 6. **Paging works** with `from`/`size` within the result window or supported field-sort `search_after`. Emulated scroll does not pin a snapshot; test paging while writes occur. See [Limits and errors](limits-and-errors.md). 7. **Idle collections handled:** a collection that has been idle can answer `503 warming_up` with a `Retry-After` header while it loads. Retry on that code, or use keep-warm. See [Idle collections and cold starts](collections.md#idle-collections-and-cold-starts). 8. **Writes in parallel:** send writes to both systems while you compare, then turn the old cluster off when you are satisfied. For Solr, see [Moving from Elasticsearch, OpenSearch or Solr](query-languages.md#moving-from-elasticsearch-opensearch-or-solr) and the [Solr](compat-solr.md) page. --- Source: https://warpsearch.io/docs/concepts # Core concepts WarpSearch stores JSON documents in collections and lets you search them with keywords, vectors or both in one query. The terms below come up throughout the docs; each links to the page that covers it in depth. ## The building blocks | Term | What it is | |---|---| | **Organization** | Your account. Collections, API keys, members and billing all belong to one organization. A person can belong to several. | | **Collection** | A named set of documents that you search together. It is the unit you create, size and delete. See [Collections](collections.md). | | **Document** | A JSON object with an `id`. Writing a document with an existing `id` replaces the old one. See [Ingesting documents](ingesting-documents.md). | | **Field** | A key in a document. Each field has a type that decides how it is searched, sorted and faceted. See [Schemas and field types](schemas-and-fields.md). | | **Schema** | The definitions of a collection's fields and templates, written as JSON or YAML and set through the WarpSearch API. See [Schemas and field types](schemas-and-fields.md). | | **Query** | What you ask for, in the query language you already know. See [Query languages](query-languages.md). | | **Facet and metric** | Counts, buckets and numbers computed over every match, in the same request as the hits. See [Facets and aggregations](facets-and-aggregations.md). | | **API key** | A `ws_...` secret with a role. See [API keys, roles and rate limits](access-control.md). | ## Documents and fields A document is a JSON object with typed fields. Nested documents keep related child fields together; see [Nested documents](schemas-and-fields.md#nested-documents) for their behavior and REST API limitations. Elasticsearch object mappings can flatten properties, which does not preserve same-child matching. ```json { "id": "b1", "title": "The Way of Kings", "genre": "fantasy", "year": 2010, "embedding": [0.12, -0.08, 0.31] } ``` Fields are typed. A `text` field is split into words and scored with BM25, so a search for `kings` finds the title above. A `string` field is matched whole, which suits filters, sorting and facets. Numbers, dates, geo points ([Geo search](geo-search.md)) and vectors have their own types. You declare types in the schema when you create the collection, or let a field-name suffix such as `_t` or `_s` choose the type. Both are described in [Schemas and field types](schemas-and-fields.md). ## Keyword, vector and hybrid search One collection serves all three. Keyword search matches words and phrases and ranks them with BM25, which suits names, codes and exact phrases; see [Full-text search](full-text-search.md) for an overview and [Searching](searching.md). Vector search finds the nearest neighbors of an embedding. You compute the embeddings and send them, because WarpSearch does not embed text for you; see [Vector search](vector-search.md). Hybrid search combines the two in one request so each covers the other's blind spots; see [Hybrid search](hybrid-search.md). Filters, sorting, facets and metrics work the same way in all three. ## Query in the language you know Every search goes to the WarpSearch API, `POST /v1/search/{c}`, and names its query `language`: search-box `text` (the default), Lucene, SQL, Elasticsearch Query DSL, Solr, LogQL, Grafana or a PPL pipeline. All of them run on the same engine, and the request's own `filters`, `sort`, `facets`, `fields` and `limit` work the same with each. `"include_translation": true` shows how WarpSearch runs a given query. See [Searching](searching.md) and [Query languages](query-languages.md). Existing Elasticsearch, OpenSearch, Solr and turbopuffer clients can point at WarpSearch unchanged instead, through the compatible endpoints under `/compat`. See [Elasticsearch](compat-elasticsearch.md) and [Moving from Elasticsearch, OpenSearch or Solr](query-languages.md#moving-from-elasticsearch-opensearch-or-solr). ## Writes, then searches A write is accepted first and becomes searchable at the next commit. You can ask for the commit as part of the write (`commit=true`) or refresh the collection after a load. Otherwise WarpSearch commits pending writes according to its configured commit interval and durability policy. The details, including what to do after a timeout, are in [Writes, visibility and durability](consistency-and-durability.md). ## Serverless by design You do not size or run anything. Data lives in durable storage, and compute is attached to a collection when you use it. The one place you notice this is the cold start: a collection that has been idle for a while is loaded on its next request, which can answer `503 warming_up` with a `Retry-After` header. You retry. The optional keep-warm setting avoids it; see [Pricing and cost control](pricing.md#cold-starts-and-keep-warm). ## Who can do what Every API key and organization member has one of four cumulative roles: `viewer` (search and read), `writer` (also write and delete documents), `editor` (also create collections and change schemas) and `admin` (also delete collections and manage members and keys). The full list of what each role allows is in [API keys, roles and rate limits](access-control.md#roles). Collection names, field names and the rest of the naming rules are in [Collections](collections.md). Limits that depend on your plan, and the errors you get when you reach them, are in [Limits and errors](limits-and-errors.md). ## Where to go next 1. [Quickstart](quickstart.md) to load data and run a first query. 2. [Collections](collections.md) and [Schemas and field types](schemas-and-fields.md) to model your data. 3. [Ingesting documents](ingesting-documents.md) and [Searching](searching.md) to build. --- Source: https://warpsearch.io/docs/collections # Collections A collection is a named set of documents with a schema. Ordinary search requests read one collection (with SQL you name it in `FROM`). Use [multi-collection queries](multi-collection-queries.md) to combine or join several collections in one request. You create, size and delete data per collection. Collections are isolated: no query can reach another organization's data, or a collection you have no role on. Every collection belongs to one organization; there are no shared or public collections. ## Names A collection name starts with a lowercase letter and then uses only lowercase letters, digits and underscores: `^[a-z][a-z0-9_]*$`. | Valid | Invalid | |---|---| | `books` | `Books` (uppercase) | | `beir_scifact` | `beir-scifact` (hyphen) | | `logs2026` | `2026_logs` (starts with a digit) | Names are unique within an organization, and the same name can exist in different organizations. A name that breaks the rule is rejected with `400 invalid_collection_name`; creating one that already exists answers `409 already_exists`. Names cannot be changed: to rename a collection, create a new one and reload your data. ## Create a collection Creating a collection needs the `editor` role. Your plan sets how many collections you can have, and creating one more answers `403 limit_exceeded`. See [Pricing](pricing.md#free-tier) and [Limits and errors](limits-and-errors.md). ::: tabs API === WarpSearch ```bash curl -X PUT https://api.warpsearch.io/v1/collections/books \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "description": "Book catalog", "class": "search", "labels": {"team": "catalog", "env": "prod"}, "metadata": {"team": "catalog"}, "schema": { "fields": { "title": {"type": "text", "analyzer": {"tokenizer": "unicode_word", "filters": ["nfkc_cf", "fold"]}}, "genre": "string", "year": "int", "embedding": {"type": "vector", "dims": 384, "metric": "cosine"} } } }' ``` === Elasticsearch Compatible with Elasticsearch clients and tools: ```bash curl -X PUT https://api.warpsearch.io/compat/es/books \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mappings": { "properties": { "title": {"type": "text"}, "genre": {"type": "keyword"}, "year": {"type": "integer"}, "embedding": {"type": "dense_vector", "dims": 384, "similarity": "cosine"} } } }' ``` === OpenSearch Compatible with OpenSearch clients and tools: ```bash curl -X PUT https://api.warpsearch.io/compat/opensearch/books \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "settings": {"index": {"knn": true}}, "mappings": { "properties": { "title": {"type": "text"}, "genre": {"type": "keyword"}, "year": {"type": "integer"}, "embedding": {"type": "knn_vector", "dimension": 384, "method": {"name": "hnsw", "space_type": "cosinesimil"}} } } }' ``` ::: The body is optional, and so is every key in it: | Key | Meaning | |---|---| | `description` | Free text, up to 2000 characters. | | `class` | What the collection is for: `search` (the default), `knowledge`, `stream`, `archive` or `queries`. See [Collection classes](#collection-classes). Fixed at creation. | | `labels` | Up to 64 string key/value pairs, such as `{"env": "prod"}`. Keys are up to 63 letters, digits, `-`, `_` or `.`, optionally with a DNS-style prefix and `/`. Keys starting `warpsearch.io/` are reserved. | | `metadata` | A JSON object of your own, up to 16 KB. Use it for owner, environment or anything you want to find later. | | `schema` | The fields and templates of the collection, as a JSON object. See [Schemas and field types](schemas-and-fields.md). | | `clone` | Copy another collection of your organization: `{"from": "books", "documents": true}`. See [Clone a collection](#clone-a-collection). | The Elasticsearch and OpenSearch tabs send their own mapping format to the compatible endpoint, which translates it into a schema. `mappings` and `settings` are not keys of the WarpSearch create call. You can also create collections in the [management console](/console/) under **Collections**, with the MCP `create_collection` tool (which takes the same `schema`), or, for existing Elasticsearch and OpenSearch clients, through the compatible `PUT /{index}` or `_bulk` API when your key may create collections. A turbopuffer namespace is created by its first write; see [turbopuffer compatibility](compat-turbopuffer.md). Plain `POST` to `/v1/collections/{c}/documents` does not create a collection; it answers `404` for one that does not exist. ### Collection classes The class lets WarpSearch pick storage and lifecycle defaults for the collection's purpose, most visibly how long it stays warm. It does not change the price per request or per GB. An unknown class answers `400 invalid_class`. | Class | For | Warmth | |---|---|---| | `search` | Catalog, site and app search, records | Released after 15 minutes idle; keep-warm offered | | `knowledge` | RAG chunks, embeddings, hybrid search | Released after 15 minutes idle; keep-warm offered | | `stream` | Logs, events, SIEM, metrics | Only recent partitions stay on NVMe; older ones load on demand when a query's time range reaches them | | `archive` | Compliance, legal hold, rarely queried history | Never warm; a cold launch is slow | | `queries` | Registered queries for the [Match API](match-api.md) (reverse search); its schema describes the documents to match | Registered queries stay ready to match; holds no documents | A new collection can be written to straight away. Define the fields you care about up front: you can add fields later, but changes that would break documents already stored are refused. See [Schemas and field types](schemas-and-fields.md#changes-that-are-refused). ## List and describe ```bash curl https://api.warpsearch.io/v1/collections \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" curl https://api.warpsearch.io/v1/collections/books \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" ``` The first call lists the collections your key can see. A collection you hold no role on is not in the list, and asking for it answers `404`, the same as for a name that does not exist. The second call describes one collection: | Field | Meaning | |---|---| | `name`, `class`, `description`, `labels`, `metadata` | What you set at creation (labels and metadata can change). | | `engine_version` | Present when WarpSearch pins the collection to an engine version. | | `fields` | Each field's `name`, `type` and whether it is `multi`-valued. `GET /v1/collections/{c}/schema` returns the full schema. | | `doc_count`, `size_bytes`, `stats_at`, `stats_status` | Size figures, cached and refreshed about once a minute. `stats_status` is `unknown` until measured, `current` for a recent measurement, or `stale` after five minutes without fresh stats. Counts are omitted when unknown or stale; a reported zero means a measured empty collection. `stats_at` records the last measurement and remains present when stale. | | `created_at`, `created_by` | When and by whom (a user or an API key). | | `time_field`, `message_field`, `default_fields`, `id_field` | Defaults the query languages use, for example which fields a bare Lucene term searches. | | `sources` | Whether the collection keeps each document's original body (its source), set by its class. Only a collection that keeps sources can be cloned with its documents or recovered. | | `damaged` | Present and `true` when the collection's storage is damaged and it may not load. See [Recover a damaged collection](#recover-a-damaged-collection). | | `clone` | Present on a collection made by a clone: `from`, `documents`, `state` (`pending`, `running`, `done`, `failed` or `cancelled`), `docs_total`, `docs_done`, `docs_lost`, `deletes_unknown`, `error`, `started_at` and `finished_at`. | The console shows the same figures on each collection's page, and `GET /v1/usage` shows organization totals against your plan's limits. ### The collection page in the console Each collection's page in the [console](/console/collections) has these tabs: - **Overview**: document count, storage, query volume, latency (p50, p95, p99) and documents ingested over the last 24 hours, 7 days or 30 days, plus the collection's class, fields and plan limits. An empty collection shows the API calls to add documents and search them. - **Documents**: run a query in any language, browse and export documents, open one document, or patch or delete many at once. - **Schema**: the collection's fields and their types. Editors can add fields here. - **Relevance** (Search, eCommerce and Knowledge collections, on paid plans): your top searches, searches that found nothing and searches that found little, a preview of any search, and the synonyms, rules and ranking settings that tune it. - **Settings**: description, labels, metadata, cloning and deleting the collection. **Search** and **Add documents** in the page header open the query tool and a paste-or-upload dialog from any tab. Traffic and latency figures are sample data for now; the page labels them until the engine reports real ones. ## Change a collection `PATCH` changes the description, metadata and labels. Metadata and labels merge key by key, and setting a key to `null` removes it: ```bash curl -X PATCH https://api.warpsearch.io/v1/collections/books \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{"metadata": {"team": null, "owner": "search"}}' ``` To add fields, send a schema with the new definitions to `PUT` `/v1/collections/{c}/schema`. The response is the resulting schema: ```bash curl -X PUT https://api.warpsearch.io/v1/collections/books/schema \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{"fields": {"rating": "float"}}' ``` Read it back with `GET /v1/collections/{c}/schema` (add `Accept: application/yaml` for YAML). Reading needs `viewer`; writing needs `editor`. See [Schemas and field types](schemas-and-fields.md) for what can and cannot change. ## Clone a collection A clone creates a new collection from an existing one in your organization. Use it for a backup before a risky change, a trial of new relevance settings, or to promote a staging collection to production. It copies: - the schema, exactly as the source has it; - the synonyms, rules and search settings; - the description, class, labels and metadata, unless the create call sets its own; - with `"documents": true`, every document, as it was at the source's last commit. ```bash curl -X PUT https://api.warpsearch.io/v1/collections/books_backup \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{"clone": {"from": "books", "documents": true}, "description": "Before the spring reindex"}' ``` | Key of `clone` | Meaning | |---|---| | `from` | The collection to copy. You need read access to it. | | `documents` | `true` copies the documents too. Defaults to `false`: schema and relevance settings only. | | `recover` | How hard to try when the source is damaged: `auto` (the default), `scan` or `off`. See [Recover a damaged collection](#recover-a-damaged-collection). | Creating a clone needs the `editor` role and counts against your plan's collections like any other create. In the console, use **Clone** on the collection's row or on its **Settings** tab. What to know: - **The copy is a snapshot.** Documents are copied as of the source's last commit when the clone starts. Later writes to the source are not copied. - **Writes wait until it is done.** A clone with documents copies them in the background. Until it finishes, writes and schema changes to the new collection answer `409 collection_cloning`; searches work and see the documents copied so far. `GET /v1/collections/{c}` shows progress in `clone` (`docs_done` of `docs_total`), and the console shows it on the collection. - **Documents are indexed again.** Each document gets the same id and body, but its `_version_` starts over in the new collection. - **To stop a clone, delete the new collection.** A failed clone keeps the schema, settings and whatever was copied; delete it and clone again. - **Partitioned collections** (and their partitions) cannot be cloned yet, and a clone cannot set `partitioning`. - **Stream collections keep no sources.** The `stream` class does not store each document's original body (logs at scale would be stored twice), so `sources` is `false` and only their schema and settings can be cloned: a clone with documents answers `409 source_not_stored`. A clone into a stream collection works; the new collection's class decides whether it keeps sources. - A clone's `schema` comes from the source and cannot be combined with your own `schema`, except when recovering a source whose schema is unreadable. ### Recover a damaged collection Documents' sources are stored apart from the search index, in a format where each block carries its own checksum. When a collection's index is damaged and it no longer loads (it shows `"damaged": true`, and searches may answer `503 recovery_required`), its documents can usually still be read back. Recovery is a clone with documents into a new collection; the console offers it as **Recover** on the damaged collection, into `_recovered` by default. ```bash curl -X PUT https://api.warpsearch.io/v1/collections/books_recovered \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{"clone": {"from": "books", "documents": true, "recover": "auto"}}' ``` Recovery reads in tiers and uses the first one that works: 1. **Index**: when the source opens cleanly, the normal clone. 2. **File list** (`recover: "auto"`): the source's last commit lists its segments, which documents are live and where each one's source is. Deletes are honored. 3. **Scan** (`recover: "scan"` only): reads every stored source file and keeps the newest version of each document. Use it when `auto` fails because the commit's file list is unreadable. `recover: "off"` fails unless the source opens cleanly. When the recovery finishes, `clone` may report: - `docs_lost`: documents in damaged blocks that could not be read, and were not copied. - `deletes_unknown: true`: a scan could not see which documents were deleted, so documents you deleted from the source may be back. Find and delete them again. Check the recovered collection (counts, a few searches), point your application at it, then delete the damaged one. If even the source's schema is unreadable, the create answers with an error; send your own `schema` beside `clone` to recover into it. ## Delete a collection ::: tabs API === WarpSearch ```bash curl -X DELETE https://api.warpsearch.io/v1/collections/books \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" ``` === Elasticsearch ```bash curl -X DELETE https://api.warpsearch.io/compat/es/books \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" ``` === OpenSearch ```bash curl -X DELETE https://api.warpsearch.io/compat/opensearch/books \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" ``` ::: This deletes the collection and every document in it. There is no undo: to keep a copy, [clone it](#clone-a-collection) with its documents first. You can then create a new collection with the same name only after background deletion finishes; until then creation answers `409 collection_deleting`. Deleting returns `202` and needs the `admin` role. > **Coming soon:** opening and closing a collection at runtime, to pause a collection without > deleting it. ## Idle collections and cold starts WarpSearch does not keep compute attached to a collection nobody is using. After a period without requests the collection is unloaded to durable storage, and the next request loads it again. While it loads, the request can answer `503` with code `warming_up` and a `Retry-After` header. This is normal, and the wait is not billed. Retry after the number of seconds in the header: ```bash curl -i https://api.warpsearch.io/v1/search/books \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{"language": "lucene", "query": "title:dune"}' # HTTP/1.1 503 Service Unavailable # Retry-After: 5 # {"code":"warming_up","detail":"the collection is loading; retry shortly", ...} ``` Build retry-with-backoff into any client that talks to a collection that may be idle, and see [Pricing](pricing.md#cold-starts-and-keep-warm) for keep-warm, which holds a collection ready. Free accounts do not include keep-warm. A free collection that is not queried or written for 30 days is deleted, and its schema is kept so you can create it again; see [Pricing](pricing.md#free-tier). ## Roles on collections Your API key's role decides what you can do with a collection: | Action | Role needed | |---|---| | List and describe | `viewer` | | Search, count, translate, get by id | `viewer` | | Index, replace and delete documents, refresh | `writer` | | Create, change schema, description, metadata or labels, force merge | `editor` | | Delete | `admin` | A role that is too low answers `403 forbidden` with a message naming the role you need. See [API keys, roles and rate limits](access-control.md). --- Source: https://warpsearch.io/docs/highlighting # Highlighting Highlighting returns excerpts of a document with matching words marked. Add `highlight` to a standard search request. You can retrieve only an ID and title while highlighting a longer body; the highlighted field does not have to be in the returned `fields` list. ## Native API Send a normal request to `POST /v1/search/articles`: ```json { "language": "lucene", "query": "body_t:climate", "fields": ["id", "title"], "highlight": { "fields": ["body_t"], "backend": "auto", "fragment_size": 150, "fragments": 2 } } ``` The native response puts snippets in each hit's `highlight` map, alongside `fields`: ```json { "id": "123", "fields": {"title": "Weather report"}, "highlight": { "body_t": ["Changing climate affects rainfall."] } } ``` Fields without a match are omitted unless `no_match_size` requests a fallback prefix. The `highlight` option also works with the other `/v1` query languages and the MCP `search` tool. For a native WarpSearch expression, use the same options with `language: "warpsearch"`: ```json { "language": "warpsearch", "query": "body_t:$term", "vars": {"term": "climate"}, "fields": ["id"], "highlight": {"fields": ["body_t"], "backend": "analysis"} } ``` [Native expression access rules](query-languages.md#native-queries-and-replays) still apply. Field aliases and field permissions apply to highlighting, including `match_fields` and `highlight_query`. Wildcard field selectors are unavailable on collections with restricted field lists. ### Replaying a highlighted search A [translation](query-languages.md#see-the-translation) of a highlighted search, from `include_translation` or the MCP `translate_query` tool, keeps the highlight in its signed `replay`. The replay's `highlight` holds the same options and fields, `match_fields`, the query `words`, `summary`, and `highlight_query` as a `warpsearch` expression with `vars`, signed with the query. Send the replay to `/v1/search/{c}` and it highlights as the original search did. A search that has no `warpsearch` form has no replay, with or without highlighting. The translation returns a warning instead; send the original request again. For highlighting, this covers: - Every `text` search with query text. - A geo `highlight_query`, which has no `warpsearch` form, like a geo query. A request whose `words` list has more than 256 entries gets no translation at all: it is rejected with `400`. ## Choose a backend | Backend | Index requirement | Work at search time | |---|---|---| | `analysis` | Stored source text | Analyze source with the matching field's analyzer and locate matching terms and phrases. | | `positions` | Stored source and indexed token positions | Read matching postings positions, then analyze the source prefix needed to map positions to source offsets. | | `stored_offsets` | A `highlight_text` field with `stored_offsets: true`, configured before indexing | Read persisted source offsets and token data without analyzing the text again. | | `auto` (default) | Source available | Select stored offsets when configured; otherwise positions when every matching representation indexes them; otherwise analysis. | Explicit selections do not silently fall back. An unavailable backend returns an error. Positions are unavailable on docs-only keyword fields and fields with `index: "none"`. No backend depends on norms; there is currently no separate text-field norms toggle in the native schema. In order of preference, `auto` uses stored offsets, then positions, then analysis. It prefers positions to analysis because they never measured slower; in a segment written without positions it uses analysis instead of failing. Stored chunks must still be read and decompressed, and character filters may process the full source; see [Performance](#performance) and benchmark your workload before choosing a backend for latency reasons. Ordinary `text` fields store source by default. A `string` or `id` field needs stored source to be highlighted; matching a keyword highlights the whole value. A field with `stored: false` cannot be highlighted from its postings alone. ### Configure stored offsets Create the field through the [native schema API](schemas-and-fields.md) before ingesting documents. For example, `PUT /v1/collections/articles` with: ```json { "schema": { "fields": { "body": { "type": "highlight_text", "params": {"analyzer": "english", "stored_offsets": true} } } } } ``` Index `body` as a string or an array of strings. Named analyzer presets are supported, including `standard` (the default), `english`, and other supported analyzer presets. Inline custom analyzer chains are not supported by this field type. Query and highlight the field by its name, `body`: ```json { "language": "lucene", "query": "body:climate", "fields": ["id", "body"], "highlight": {"fields": ["body"], "backend": "stored_offsets"} } ``` Use `text`, `lucene` or `es` queries on `highlight_text` fields. Raw `warpsearch` expressions do not resolve these fields in the same way. `stored_offsets: false` keeps source and indexed positions, so analysis and positions remain available. Enabling stored offsets or changing the analyzer requires reindexing. Existing plain text fields do not gain offsets retroactively. Elasticsearch mapping options such as `term_vector` and `index_options` do not configure stored offsets; use the native field configuration above. ## Fragment and rendering options Use defaults at the top level and override them inside a field's object: ```json { "language": "lucene", "query": "title:climate OR body_t:climate", "highlight": { "encoder": "html", "fields": { "title": {"backend": "analysis", "fragments": 0}, "body_t": {"backend": "positions", "fragment_size": 150, "fragments": 2} } } } ``` | Option | Default | Meaning | |---|---|---| | `fields` | Required | Field name, list of names, or map of names to options. `*` patterns select eligible fields on unrestricted collections. | | `fragment_size` | `100` | Target fragment length in Unicode code points; matches stay whole. Ignored when `fragment_words` is set. | | `fragment_words` | Unset | Fragment length in words instead of code points. See [Fragment length in words](#fragment-length-in-words). | | `fragments` | `1` | Maximum fragments across the field's values; `0` returns whole matching values, subject to limits. | | `fragment_selection` | `best` | `first`, `fast`, `estimate` or `best`: how much of a value is read to choose fragments. See [Fragment selection](#fragment-selection-speed-or-fragment-quality). | | `pre_tag`, `post_tag` | ``, `` | Markup around matches. | | `pre_tags`, `post_tags` | Unset | Lists of 1 to 64 tags, taken in turn by the query's terms and phrases. Cannot be combined with `pre_tag` / `post_tag` at the same level. | | `tags_schema` | Unset | `styled`: `` to ``, closed with ``. | | `encoder` | `html` | Escape source text; `none` returns it verbatim. Tags are caller-supplied markup. | | `boundary` | `word` | `word`, `sentence`, or `none`. Sentence boundaries use bounded punctuation scanning. | | `boundary_max_scan` | `20` | Extra code points considered for sentence boundaries. | | `order` | `position` | Return fragments in source order, or `score` order. | | `phrase_spans` | `true` | Mark a matching phrase as one span; false marks its matched tokens individually. | | `require_field_match` | `true` | Restrict matching to the highlighted logical field. False applies positive query terms to other highlighted fields too. | | `match_fields` | Empty | Explicit same-source representations, such as variants. Cross-source offset mapping is rejected. | | `no_match_size` | `0` | Return a source prefix when there is no lexical match. | | `ellipsis` | Empty | Text inserted at clipped value edges. | | `max_analyzed_chars` | `1000000` | Code point limit for the field as a whole: the values of an array share it in order, and once one is cut the later values are not analyzed. Matches past it are not highlighted, and truncation produces a warning. | | `format` | `tagged` | Strings, or `offsets` objects as shown below. | | `summary` | `false` | Request level only. Return each fragment as a match summary object. See [Match summaries](#match-summaries). | | `words` | Unset | Request level only. The query words that summaries report as matched; a list you send holds up to 256. The `text` language fills them in. | | `highlight_query` | Ranking query | Request-level override using the request's filter/clause syntax: Elasticsearch DSL, Solr query strings, native expressions, or Lucene clauses for the other languages. It does not change matching or ranking. | All queried variants of a logical field contribute source-offset matches. Fragments never join separate array values. Phrase occurrences are verified, while negative clauses and separately supplied filters do not contribute spans. Highlighting extracts positive lexical matches; it is not a complete explanation of Boolean matching or vector similarity. For vector-only searches, supply a lexical `highlight_query` if you want highlighted text. ### Fragment count, length and markup The same settings exist in every API. Elasticsearch, OpenSearch and Solr requests map to the native options: | Need | Native option | Elasticsearch / OpenSearch | Solr | |---|---|---|---| | Number of fragments | `fragments` (default 1; `0` returns whole values) | `number_of_fragments` (default 5) | `hl.snippets` (default 1) | | Fragment length | `fragment_size` in code points (default 100), or `fragment_words` in words | `fragment_size`, or `fragment_words` (WarpSearch extension) | `hl.fragsize` | | Marker tags | `pre_tag` / `post_tag` (default ``, ``) | `pre_tags` / `post_tags` with one tag each | `hl.tag.pre` / `hl.tag.post` | | One tag per query term | `pre_tags` / `post_tags` lists of 1 to 64 tags | `pre_tags` / `post_tags` arrays | Comma-separated `hl.tag.pre` / `hl.tag.post` | | Built-in styled tags | `tags_schema: "styled"` | `tags_schema: "styled"` | Not available | | Escaping | `encoder`: `html` (default) or `none` | `encoder` (default `none`) | `hl.encoder` (default `none`) | | No match | `no_match_size` | `no_match_size` | `hl.defaultSummary` | | Fragment edges | `boundary`: `word`, `sentence` or `none`; `boundary_max_scan` | `boundary_scanner` (default `sentence`), `boundary_max_scan` | `hl.bs.type`, `hl.bs.maxScan` | | Order | `order`: `position` or `score` | `order` | Not available | | Speed against quality | `fragment_selection` | `fragment_selection` (WarpSearch extension) | `hl.fragmentSelection` (WarpSearch extension) | The `html` encoder escapes the source text, not the tags: tags are inserted as given, so only send tags you trust. #### Tag lists and styled tags With `pre_tags` and `post_tags`, each query term or phrase gets its own markup. Term *i* (in query order) opens with `pre_tags[i % n]` and closes with `post_tags[i % m]`, where `n` and `m` are the list lengths, as in Elasticsearch. A query for `cat dog` with `"pre_tags": ["", ""], "post_tags": ["", ""]` marks `cat` and `dog`: ```json { "language": "lucene", "query": "body_t:cat OR body_t:dog", "highlight": { "fields": ["body_t"], "pre_tags": ["", ""], "post_tags": [""] } } ``` `tags_schema: "styled"` is a ready-made list of ten tags, `` to ``, each closed with ``. Style the `hlt1` to `hlt10` classes in your page. A `pre_tag` or `pre_tags` at the same or the field level overrides the styled opening tags. A level holds either the single form (`pre_tag`) or the list (`pre_tags`), not both; the same applies to the closing tags. A field's own tags replace the request's. Tags are resolved in this order: the field's tags, the field's `tags_schema`, the request's tags, the request's `tags_schema`, then `` / ``. Invalid values return HTTP 400 naming the option. ### Fragment selection: speed or fragment quality `fragment_selection` sets how hard the highlighter looks for the best fragments, and so how much of each value it reads. Every mode highlights only real matches. A cheaper mode never marks a word that did not match; it may only return a less relevant fragment. That is why the option is named after fragment selection rather than accuracy. | `fragment_selection` | Reads | Picks | |---|---|---| | `best` (default) | Every match up to `max_analyzed_chars` | The best-scoring fragments of the whole value. All backends return the same output. | | `estimate` | With postings positions: up to the windows chosen from positions alone. Without positions, the same as `fast`. | The best fragments of what it read; usually what `best` picks. | | `fast` | Until it holds `fragments` separate matching windows and one window containing every query term or phrase the document holds | The best fragments of what it read. | | `first` | Until it holds `fragments` separate matching windows | The best of the first matching windows. | ```json { "language": "lucene", "query": "body_t:prince", "highlight": { "fields": ["body_t"], "backend": "positions", "fragment_selection": "estimate" } } ``` Each mode reads one fragment's worth of text past the last window it needs, so fragment edges are cut exactly as `best` would cut them. `first` costs about as much as reaching the first matches, not the length of the value: a 1 MB document whose first match is near its start costs about what a short one does. The modes apply to the `analysis` and `positions` backends, and only to tagged fragments. The `stored_offsets` backend does no analysis, so it has nothing to save. `format: "offsets"` and `fragments: 0` always read the whole value. `estimate` needs postings positions: the `positions` backend, or `auto` on a field that indexes positions. It works in four steps: 1. The query's matches come from postings positions, and phrases are verified there. 2. A window's size in positions is `fragment_size` divided by the value's characters per position, measured on its first 256 tokens. Windows are scored as text fragments are. 3. Analysis stops just past the last match the chosen windows hold. 4. The exact selection then runs over everything read so far, so the result is never worse than the position-only choice. It can still miss a better window further on when an estimated window edge is off by a few words. `fast` learns which query terms a document holds from postings, then reads until one window holds every one of them. Which mode to use: - `best` for short values, such as product titles, descriptions and most CMS fields. At 1 KB every mode costs the same, and only `best` returns the same fragments on every backend. - `estimate` for long documents on fields with positions. Collections that hold long documents should set it on their requests, since the default stays `best`. - `fast` for long documents on fields without positions. - `first` when any matching fragment will do, for example autocomplete or large result pages. Elasticsearch and OpenSearch requests accept `fragment_selection` inside `highlight` or inside a field, and Solr requests accept `hl.fragmentSelection` (or `f..hl.fragmentSelection`). These are WarpSearch extensions; Elasticsearch, OpenSearch and Solr have no equivalent setting. There is no per-collection default; without the option, `best` applies. ### Source offsets `format: "offsets"` returns unescaped source text and spans instead of injecting markup: ```json { "text": "a cat", "value_index": 0, "start": 10, "end": 15, "spans": [[2, 5]] } ``` `start` and `end` are half-open UTF-8 byte offsets into the original value. Each span is a half-open UTF-8 byte range relative to `text`. `value_index` identifies the original array value. Fragment sizes and analysis limits count code points, not bytes or JavaScript UTF-16 units. Offset objects can carry more facts about the whole value the fragment was cut from, such as `matched_words` when the request sets `words`. Match summaries turn these into a ready-to-render form. ### Fragment length in words `fragment_words` sets the fragment length in words instead of code points. A fragment holds the matched words, about a third of the budget before them and the rest after them, and never less than the match itself. It takes a positive integer up to 100000, at the request level or per field, and `fragment_size` is ignored when it is set: ```json { "language": "lucene", "query": "body_t:climate", "highlight": { "fields": {"title": {"fragments": 0}, "body_t": {"fragment_words": 12}}, "fragment_words": 8, "fragments": 1 } } ``` Here `body_t` fragments hold about 12 words, `title` returns whole values, and any other field listed without its own setting would use 8 words. Elasticsearch and OpenSearch requests accept `fragment_words` as a WarpSearch extension, at the request or field level. Solr requests have no equivalent parameter. ## Match summaries `summary: true` returns each fragment as an object that says how well the value matched the query words, in the style of Algolia's `_highlightResult`. Use it to show which of the user's words a result matched, or to style a full match differently from a partial one. It is available on `POST /v1/search/{collection}` and the MCP `search` tool, with any query language. ```json { "language": "text", "query": {"text": "samsung tv", "fields": ["title"]}, "fields": ["id", "title"], "highlight": { "fields": ["title"], "summary": true, "pre_tag": "", "post_tag": "" } } ``` With a `tv, television` synonym on the collection, a hit titled "Samsung television" returns: ```json { "id": "p1", "fields": {"title": "Samsung television"}, "highlight": { "title": [ { "value": "Samsung television", "match_level": "full", "matched_words": ["samsung", "tv"], "fully_highlighted": true } ] } } ``` | Key | Meaning | |---|---| | `value` | The fragment with its matches between `pre_tag` and `post_tag` (default `` and ``). The text is HTML-escaped unless `encoder` is `none`. Overlapping or adjacent matches share one tag pair. | | `match_level` | `full` when every query word matched in the value, `partial` when some did, `none` when none did. | | `matched_words` | The query words that matched in the value, in query order, as the user typed them. | | `fully_highlighted` | `true` when every word of the value is inside a match. | `match_level`, `matched_words` and `fully_highlighted` describe the whole value the fragment was cut from, not only the fragment. A hit titled "Samsung galaxy phone" searched for `samsung galaxy` is a `full` match whose value is not fully highlighted: ```json { "value": "Samsung galaxy phone", "match_level": "full", "matched_words": ["samsung", "galaxy"], "fully_highlighted": false } ``` To get one summary per value, set `fragments: 0`, which returns each matching value whole. Summaries are built from the `offsets` format, so `summary: true` sets `format: "offsets"` for the request. A summary uses only the first tag of a `pre_tags` / `post_tags` list or of `tags_schema: "styled"`; the other tags in the list are not used. `summary` and `words` are request-level options; inside a field's options they return HTTP 400. Elasticsearch, OpenSearch and Solr requests cannot ask for summaries, and Solr's `hl.defaultSummary` is the unrelated no-match fallback described under [Solr and SolrJ](#solr-and-solrj). ### Query words and the text language `match_level` and `matched_words` are measured against the request's query words. - With `"language": "text"`, `words` defaults to the words of the query text. A word also counts as matched when the highlighted term is one of its synonyms, is within its typo tolerance, or, for the last word, starts with it. A search for `televsion` (a typo) or `telev` (a prefix) reports `matched_words: ["televsion"]` or `["telev"]`, with `television` highlighted in `value`. - With any other language, list the words yourself in `words` (up to 256 strings). Each word is analyzed with the field's analyzer, and a word matches when one of its terms is highlighted; synonyms, typos and prefixes are not traced back to it. - Without `words`, `matched_words` is empty and `match_level` is `none` even when `value` contains matches. ```json { "language": "lucene", "query": "title:dune", "highlight": {"fields": ["title"], "summary": true, "words": ["dune"]} } ``` A `text` request that lists `words` different from its query text uses them as given, without the synonym, typo and prefix tracing. ## Elasticsearch and OpenSearch Use the normal `highlight` object on `POST /compat/es/articles/_search` or `POST /compat/opensearch/articles/_search`: ```json { "query": {"match": {"body_t": "climate"}}, "_source": ["title"], "highlight": { "type": "unified", "encoder": "html", "pre_tags": [""], "post_tags": [""], "fields": { "body_t": {"fragment_size": 150, "number_of_fragments": 2} } } } ``` Each entry in `hits.hits` carries a `highlight` map. It is independent of `_source` and is returned even with `_source: false`. `_msearch`, hybrid/fusion searches, collapsed inner hits, and `top_hits` aggregations support highlighting too. Grafana's Elasticsearch/OpenSearch requests use the same compatibility endpoints. | Elasticsearch / OpenSearch setting | WarpSearch behavior | |---|---| | `type: "unified"` (default) | `auto` backend. | | `type: "plain"` | Analysis backend. | | `type: "fvh"` | Stored-offset backend; requires the native `highlight_text` configuration above. | | `fields` | Object or array of one-field objects; per-field options supported. | | `number_of_fragments` | `fragments`; default `5`, and `0` returns whole matching values. | | `fragment_size`, `no_match_size`, `order`, `encoder` | Corresponding native options. Compatibility encoder defaults to `none`; set `html` when rendering source as HTML. A `fragment_size` above 1000000 (Kibana sends 2147483647) is clamped to 1000000; `number_of_fragments` still applies. | | `pre_tags`, `post_tags` | A string or an array of 1 to 64 tags. With several tags, the query's terms take them in turn for every `type` (Elasticsearch does this only for `fvh`). | | `tags_schema` | `styled` maps to the native styled tags; `default` sets `` / `` unless that level names its own tags. | | `fragment_selection` | WarpSearch extension, at the request or field level: `first`, `fast`, `estimate` or `best` (default). See [Fragment selection](#fragment-selection-speed-or-fragment-quality). | | `fragment_words` | WarpSearch extension, at the request or field level: fragment length in words. See [Fragment length in words](#fragment-length-in-words). | | `require_field_match` | Supported; default true. | | `matched_fields` | Same-source `match_fields`. | | `highlight_query` | A request-level Elasticsearch Query DSL clause, authorized like the search query. | | `boundary_scanner` | `word` or `sentence`; default sentence. | | `boundary_max_scan` | Native bounded boundary scan. | | `max_analyzed_offset` | Positive values set the code point limit; `-1` uses the native default. | These type names select WarpSearch backends, not Lucene implementations. Fragment boundaries, scoring, and character-limit semantics can differ. Semantic highlighters, `phrase_limit`, `fragmenter`, `fragment_offset`, custom boundary characters, locale-specific boundary scanners, and per-field `highlight_query` are rejected with `unsupported_feature`. Highlighting inside nested `inner_hits` is also unsupported; see [Nested documents](schemas-and-fields.md#nested-documents) for REST API limitations. ## Solr and SolrJ Use standard Solr highlighting parameters on `/compat/solr/articles/select`: ```bash curl 'https://api.warpsearch.io/compat/solr/articles/select?q=body_t:climate&fl=id,title&hl=true&hl.fl=body_t&hl.snippets=2&hl.fragsize=150&hl.encoder=html' \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" ``` Solr responses contain the usual separate `highlighting` object, keyed by document ID: ```json { "highlighting": { "123": {"body_t": ["Changing climate affects rainfall."]} } } ``` The JSON Request API accepts the same settings inside `params`. Form-encoded requests and `wt=javabin` are supported; SolrJ receives the corresponding named-list structure. | Solr parameter | Behavior | |---|---| | `hl=true` | Enable highlighting. | | `hl.fl` | Comma/space-separated or repeated fields; defaults to `df` or collection default fields. | | `hl.method=unified` | Auto backend (default). | | `hl.method=original` | Analysis backend. | | `hl.method=fastVector` | Stored-offset backend; requires `highlight_text`. | | `hl.snippets`, `hl.fragsize` | Fragment count (default 1) and size (default 100). `hl.fragsize=0` requests whole matching values; otherwise `hl.snippets=0` disables that field. | | `hl.tag.pre`, `hl.tag.post` | Tags; take precedence over `hl.simple.pre` / `hl.simple.post`. A comma-separated value is a list of up to 64 tags that the query's terms take in turn, for every `hl.method`. | | `hl.fragmentSelection` | WarpSearch extension: `first`, `fast`, `estimate` or `best` (default). See [Fragment selection](#fragment-selection-speed-or-fragment-quality). | | `hl.encoder` | `none` by default, or `html`. | | `hl.requireFieldMatch` | False by default, so terms may highlight other requested fields. | | `hl.q`, `hl.qparser` | Separate highlighting query and its parser. | | `hl.maxAnalyzedChars` | Code point limit; default 51200. `-1` uses the native maximum, still subject to resource limits. | | `hl.bs.type`, `hl.bs.maxScan` | `WORD` / `SENTENCE` boundaries and maximum scan distance. | | `hl.defaultSummary=true` | Return a prefix when no matching fragment exists. | Per-field forms such as `f.body_t.hl.fragsize=200` are supported. Grouped document lists can carry highlights. `hl.usePhraseHighlighter` and `hl.highlightMultiTerm` must remain true. Alternate fields, custom fragmenters/formatters, scoring tunables, and other unmapped `hl.*` settings are rejected. Solr method names select the backends above; they do not reproduce Solr's fragment scoring exactly. Tag lists are split the way Solr's FastVector highlighter splits them: each tag is trimmed and trailing empty tags are dropped. A value without a comma stays one tag, unchanged. In Solr only `fastVector` splits the value, while `unified` and `original` treat it as one tag; here every method splits it, so a single tag that contains a comma cannot be expressed. ## Performance Highlighting cost grows with the amount of text analyzed, so long documents dominate it. The table shows local benchmark results: War and Peace cut into 1 KB, 10 KB, 100 KB and 1 MB documents, one `english` text field (or a `highlight_text` field for `stored_offsets`), `fragments: 1`, `fragment_size: 100`, 10-hit pages (3 for 1 MB), a release build on one thread. Each cell is the median latency added per highlighted hit, in microseconds: the same search with and without `highlight`, for the query `prince`, which occurs in every document: | Backend and `fragment_selection` | 1 KB | 10 KB | 100 KB | 1 MB | |---|---|---|---|---| | `analysis`, `best` | 12 | 94 | 800 | 8221 | | `positions`, `best` | 12 | 93 | 741 | 8127 | | `stored_offsets`, `best` | 3 | 32 | 312 | 3383 | | `positions`, `estimate` | 12 | 40 | 275 | 3171 | | `positions`, `fast` | 12 | 18 | 111 | 333 | | `analysis`, `first` | 12 | 18 | 109 | 334 | `best` against `estimate` (both on `positions`) for other queries: | Query | 10 KB | 100 KB | 1 MB | |---|---|---|---| | `pierre OR natasha` | 83 → 40 | 733 → 320 | 7798 → 5498 | | `borodino OR cossack` (rare terms) | 47 → 35 | 694 → 254 | 7273 → 3573 | | `"prince andrew"` (phrase) | 86 → 49 | 730 → 338 | 7927 → 764 | | `nap*` (prefix) | 43 → 34 | 647 → 451 | 7588 → 1624 | What the numbers show: - At 1 KB every mode costs the same. The choice matters only for long values. - `best` is bound by the analyzer, about 5 ns per byte with `english`, so it grows linearly with the value. - `positions` was never slower than `analysis`, and it is up to twice as fast for rare terms and prefixes on 10 KB values, because it stops analyzing after the last occurrence. - `stored_offsets` is about 2.5 times faster than analysis for `best`, at the cost of storing every token at index time. - `estimate` costs what reading up to the chosen windows costs: on average about half of `best`, and up to ten times less for the 1 MB phrase query. Its fragments are identical to `best`'s 77% of the time, and they hold 98% of the matches `best` highlights. Most differences are near-ties; real misses happen when two matches are close in positions but too far apart in characters to fit one fragment. - `fast` equals `first` for a single term, phrase or prefix. For several terms it reads until one window holds every term the document contains, which can be most of the value when they never meet: 5807 µs for `borodino OR cossack` over 1 MB, against 3573 for `estimate`. Over positions, `estimate` is usually the better middle mode; `pierre OR natasha` over 1 MB is the exception, at 3872 µs for `fast` against 5498 for `estimate`. - `first` costs what reading up to the first matches costs. A term whose first occurrence is deep in the value saves less: a rare term over 1 MB took 1176 µs. - With 100-hit pages the cost per hit is the same or lower: for `prince` over 10 KB, 69 µs for `best` over positions, 43 for `estimate`, 32 for `first` and 29 for `stored_offsets`. These results set the defaults. `auto` uses stored offsets when they are configured, then positions, then analysis. `best` stays the default `fragment_selection`: it is the only mode whose output is the same on every backend, and short values, such as most product and CMS fields, cost the same in every mode. Requests on collections with long documents should set `estimate`. These measurements exclude HTTP and network overhead. Benchmark your own documents and queries before relying on them. ### Known limits - Analysis starts at the beginning of each value. On long values, `estimate` can reduce work but may choose different fragments from `best`. Use `best` when fragment quality matters more than latency. - `max_analyzed_chars` (Elasticsearch `max_analyzed_offset`, Solr `hl.maxAnalyzedChars`) bounds the work per field: the values of an array share one budget in order, and once a value is cut the later values are not analyzed. Matches beyond it are not highlighted, and the response carries a truncation warning. - For long documents that are highlighted often, a `highlight_text` field with `stored_offsets: true` avoids query-time analysis entirely. ## Other query languages and limits SQL, PostgreSQL-style SQL, Lucene, Grafana models and LogQL searches can request native `highlight` through `/v1`. PostgreSQL's `ts_headline()` SELECT expression remains unsupported; use the request option instead. There is no Loki HTTP API, and the turbopuffer compatibility API does not define a highlighting option. Highlighting applies to the returned page and does not change document membership, order or scores. Normal plan limits, collection permissions and timeouts still apply. Highlight queries count toward query byte, clause and depth limits. At most 64 highlighted field selectors and 100 fragments per field are allowed. The longest opening tag plus the longest closing tag a field uses may total at most 4096 bytes. A wildcard selecting more than 64 eligible fields is also rejected. Work is bounded by source, token, phrase and passage-selection limits. Request-level native `max_expansions` (default 4096) and `max_terms_examined` (default 100000) bound dictionary work. Exceeding these limits fails explicitly. Source truncation returns a warning and never invents a match from a partial token. See [Limits and errors](limits-and-errors.md). --- Source: https://warpsearch.io/docs/schemas-and-fields # Schemas and field types A schema tells WarpSearch how to treat each field: whether to split text into words, keep values whole, compare numbers, bucket dates or index vectors. You give a collection a schema when you create it, read it back at any time, and extend it as your data grows. For common cases you can skip the declaration: a field-name suffix such as `_t` or `_s` chooses the type for you. On native-schema collections, there is no dynamic typing beyond suffixes and templates. Elasticsearch and OpenSearch mappings also support [dynamic mapping](compat-elasticsearch.md#mappings). A field that has no definition and matches no template is rejected when you index the document, so a typo cannot create a new field. The examples use the WarpSearch API and its native schema format. Where the Elasticsearch, OpenSearch or Solr compatible APIs support the same operation, extra tabs show it there. See [Elasticsearch](compat-elasticsearch.md), [OpenSearch](compat-opensearch.md) and [Solr](compat-solr.md). ## The schema document A schema is one object with up to three top-level keys. The schema endpoints (`PUT` and `GET`) accept it as JSON or YAML: a body that starts with `{` is read as JSON, anything else as YAML. The create-collection call takes a JSON body, so there the `schema` is a JSON object. | Key | Holds | |---|---| | `fields` | Definitions of individual fields, keyed by field name. | | `templates` | Definitions that apply to every field whose name ends with the template name, such as `_attr`. | | `stored_resources` | Optional groups that control how stored text is compressed. Most schemas do not need it. | A definition is either a bare type name (`"int"`) or an object of options. ::: tabs Format === JSON ```json { "fields": { "title": {"type": "text", "analyzer": {"tokenizer": "unicode_word", "filters": ["nfkc_cf", "fold"]}}, "brand": "string", "tags": {"type": "string", "multi": "set"}, "year": {"type": "int", "index": "range"}, "price": "double", "added": "date", "store": "geo_point", "embedding": {"type": "vector", "dims": 384, "metric": "cosine"} }, "templates": { "_attr": "string" } } ``` === YAML ```yaml fields: title: type: text analyzer: tokenizer: unicode_word filters: [nfkc_cf, fold] brand: string tags: {type: string, multi: set} year: {type: int, index: range} price: double added: date store: geo_point embedding: {type: vector, dims: 384, metric: cosine} templates: _attr: string ``` ::: A schema you read back is always valid input for a write, so you can edit a schema by reading it, changing it and sending it back. ## Field types | Type | Use it for | Notes | |---|---|---| | `text` | Titles, descriptions, article bodies | Split into words by an analyzer and searched with BM25. Cannot be sorted or faceted by whole value; add a `string` variant for that. | | `string` | Categories, tags, codes, anything matched whole | Exact match, filtering, sorting, faceting. Not split into words. | | `int` | Counts, years, quantities | Signed 64-bit integer. | | `float` | Measurements | 32-bit floating point. | | `double` | Prices, scores, anything needing precision | 64-bit floating point. | | `date` | Timestamps | ISO-8601 text or epoch milliseconds, kept to the millisecond, or to the nanosecond with `unit: "ns"`. See [Dates](#dates). | | `boolean` | Flags | `true` or `false` (also the strings `"true"` and `"false"`), stored as 1 or 0. Returned as JSON booleans. | | `ip` | IPv4 and IPv6 addresses | Stored as a 16-byte value, so `10.0.0.1` and `::ffff:10.0.0.1` are the same address. Match an address or a CIDR block (`10.0.0.0/8`), or a range of addresses. Prefix, wildcard and regex queries are rejected. | | `decimal` | Money and other fixed-point numbers | Needs `scale`, the number of digits after the decimal point (0 to 18). A value with more fractional digits is rejected, not rounded. | | `geo_point` | Locations | Send `[longitude, latitude]`, or GeoJSON, WKT, `"lat,lon"` or a geohash. Define it, or use the `_p` and `_ps` suffixes. See [Geo points and queries](geo-points-and-queries.md). | | `geo_shape` | Areas, lines and points | GeoJSON or WKT. See [Geo shapes](geo-shapes.md). | | `vector` | Embeddings | Needs `dims` and, to search by nearest neighbor, a `metric`. See [Vector fields](#vector-fields). | | `id` | The document id | Reserved for the built-in `id` field. | ### Nested documents Nested documents keep the fields of each object in an array together. For example: ```json {"id": "shirt", "items": [{"color": "red", "size": "S"}, {"color": "blue", "size": "L"}]} ``` A nested query for a red size-L item must match both conditions in the same item, so this product does not match. Flattening the array loses that association and can incorrectly combine the color of one item with the size of another. Nested indexing supports several levels of child objects. Replacing or deleting a parent also replaces or deletes its children; children are not independently addressable documents. **REST API limitation:** nested schemas and queries are not currently available through the REST APIs described in this guide. This includes Elasticsearch `nested`, nested `inner_hits` and nested aggregations. Use a document per item when you need to query individual objects through these APIs, and keep a parent id to group the results. Elasticsearch `join` fields and parent/child document APIs remain unsupported. For relationships between independently identified documents, see [Graph search](graph.md). ### Text versus string Both accept strings, but they make different things searchable. Take the value `"Red Bicycle"`: - In a `text` field it becomes the words `red` and `bicycle`. A search for `bicycle` matches, and so does the phrase `"red bicycle"`. - In a `string` field it stays `Red Bicycle`. Only that exact value matches, and you can sort and facet on it. When one value needs both, give the field a `string` [variant](#variants). ## Field options Every option is optional. An option you leave out is inherited from the definition's `parent`, and otherwise takes the type's default. The schema you read back stays as sparse as the one you wrote. | Option | Applies to | Meaning | |---|---|---| | `type` | all | One of the [field types](#field-types). Required unless inherited from a `parent`. | | `parent` | all | Inherit every unset option from another field or template, such as `_t`. | | `index` | all | `match` (a term index, for exact and text queries), `range` (a points index for fast numeric and geo ranges) or `none`. Text and strings index for `match` by default. Numbers live in a column and are scanned, which suits most workloads; set `range` when range queries must be fast. | | `column` | non-text | Keep a per-field column of values, which sorting, faceting and numeric queries use. On by default for non-text types. | | `multi` | all | `false` (one value), `true` (the type's default multi-value mode), `"set"` (sorted and de-duplicated) or `"array"` (source order and repeats kept). | | `analyzer` | `text` | A registered analyzer name, or an object of `tokenizer`, `filters` and `char_filters`. See [Analyzers](#analyzers). | | `normalizer` | `string` | A list of filters applied to each whole value, such as `lowercase`, `nfkc_cf`, `fold` or `trim`. See [Normalizers](analysis-components.md#normalizers). | | `long_terms` | `string`, `text` | What to do with a term over 255 bytes: `hash128` (default; keeps long values distinct), `truncate` (keep the first 255 bytes, so values can merge) or `reject` (fail the document). | | `stored` | `text`, `string` | Keep the original text so it can be returned. On by default for `text` only. | | `stored_resource` | `text`, `string` | Name of a `stored_resources` group. Group names start and end with `_`, for example `_stored_logs_`. | | `variants` | scalar, vector, geo | Other ways of indexing the same value. See [Variants](#variants). | | `defaults` | fields with variants | `{search, value}`: which representation a bare field name means for searching and for sorting and faceting. | | `scale` | `decimal` | Digits after the decimal point, 0 to 18. Required for `decimal`. | | `unit` | `date` | `ms` (default) or `ns`: the precision dates are stored and compared at. It cannot change once set. | | `dims` | `vector` | Number of components. | | `metric` | `vector` | `l2`, `ip`, `cosine` or `none` (stored, not searchable). | | `normalized` | `vector` | Cosine only. You promise that every vector already has unit length. | | `normalize_on_write` | `vector` | Cosine only. On by default: vectors are stored at unit length. | | `truncate_dims` | `vector` | Keep only the first N components, for Matryoshka models. See [Matryoshka embeddings](matryoshka-and-dimensions.md). | | `ann` | `vector` | Approximate index settings: `codec` (`pq` or `rabitq`), `nlist`, `pq: {m, bits}` and `rabitq: {bits, query_bits}`. See [Vector search](vector-search.md). | Unknown options are rejected with a `400` that names them. ### Names Field names use ASCII letters, digits and `_`, start with a letter, never contain `__` and are at most 127 characters. Template names are `_` followed by letters, digits or `_`. A schema holds at most 5000 fields and templates together. ## Create a collection with a schema Send the schema under `schema` when you create the collection. Creating needs the `editor` role. ::: tabs API === WarpSearch ```bash curl -X PUT https://api.warpsearch.io/v1/collections/products \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "description": "Product catalog", "schema": { "fields": { "name": {"type": "text", "variants": {"s": "string"}}, "brand": "string", "price": "double", "released": "date", "location": "geo_point", "embedding": {"type": "vector", "dims": 768, "metric": "cosine"} } } }' ``` === Elasticsearch The same collection through the Elasticsearch-compatible endpoint, with an Elasticsearch mapping: ```bash curl -X PUT https://api.warpsearch.io/compat/es/products \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mappings": { "properties": { "name": {"type": "text", "fields": {"keyword": {"type": "keyword"}}}, "brand": {"type": "keyword"}, "price": {"type": "double"}, "released": {"type": "date"}, "location": {"type": "geo_point"}, "embedding": {"type": "dense_vector", "dims": 768, "similarity": "cosine"} } } }' ``` === OpenSearch The same collection through the OpenSearch-compatible endpoint. Vectors use `knn_vector`: ```bash curl -X PUT https://api.warpsearch.io/compat/opensearch/products \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "settings": {"index": {"knn": true}}, "mappings": { "properties": { "name": {"type": "text", "fields": {"keyword": {"type": "keyword"}}}, "brand": {"type": "keyword"}, "price": {"type": "double"}, "released": {"type": "date"}, "location": {"type": "geo_point"}, "embedding": {"type": "knn_vector", "dimension": 768, "method": {"name": "hnsw", "space_type": "cosinesimil"}} } } }' ``` ::: An Elasticsearch or OpenSearch mapping is translated into a WarpSearch schema when the collection is created, so you can read the result back with `GET /v1/collections/products/schema`. The translation maps `text` to `text`, `keyword` to `string`, the integer types to `int`, `float` and `half_float` to `float`, `double` to `double`, `scaled_float` to `decimal` (with a power-of-ten `scaling_factor`; values are rounded to it when written), `boolean` to `boolean`, `ip` to `ip`, `date` to `date`, `date_nanos` to a `date` with `unit: "ns"`, `geo_point` to `geo_point`, and `dense_vector` and `knn_vector` to `vector`. Details and limits are in [Elasticsearch](compat-elasticsearch.md) and [OpenSearch](compat-opensearch.md). The `create_collection` tool of the MCP server takes the same object as its `schema` argument. See [Guide for AI agents](agents.md). ## Read the schema ::: tabs API === WarpSearch ```bash curl https://api.warpsearch.io/v1/collections/products/schema \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" # the same schema as YAML curl https://api.warpsearch.io/v1/collections/products/schema \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Accept: application/yaml" ``` === Elasticsearch ```bash curl https://api.warpsearch.io/compat/es/products/_mapping \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" ``` === OpenSearch ```bash curl https://api.warpsearch.io/compat/opensearch/products/_mapping \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" ``` === Solr Field types are reported as Solr names such as `text_general`, `string` and `pdouble`: ```bash curl https://api.warpsearch.io/compat/solr/products/schema/fields \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" ``` ::: Reading needs the `viewer` role. `GET /v1/collections/{c}` also lists each field with its type. ## Add and change fields `PUT` on the schema takes a schema document and sets the fields and templates it names, leaving everything else in the schema alone. A field you name has its whole definition replaced, so send the complete definition, not a fragment. Setting needs the `editor` role, and the response is the resulting schema. ::: tabs API === WarpSearch ```bash curl -X PUT https://api.warpsearch.io/v1/collections/products/schema \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{"fields": {"rating": "float", "sku": "string"}}' ``` The body can be YAML as well: ```bash curl -X PUT https://api.warpsearch.io/v1/collections/products/schema \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/yaml" \ --data-binary $'fields:\n rating: float\n sku: string\n' ``` === Elasticsearch `PUT /{index}/_mapping` adds fields: ```bash curl -X PUT https://api.warpsearch.io/compat/es/products/_mapping \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{"properties": {"rating": {"type": "float"}, "sku": {"type": "keyword"}}}' ``` === OpenSearch A new vector field through `PUT /{index}/_mapping`: ```bash curl -X PUT https://api.warpsearch.io/compat/opensearch/products/_mapping \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{"properties": {"image_embedding": {"type": "knn_vector", "dimension": 512, "method": {"name": "hnsw", "space_type": "l2"}}}}' ``` === Solr The Solr Schema API's `add-field`: ```bash curl -X POST https://api.warpsearch.io/compat/solr/products/schema \ -H "Authorization: Bearer $WARPSEARCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{"add-field": [{"name": "rating", "type": "pfloat"}, {"name": "sku", "type": "string"}]}' ``` ::: Adding a field never touches existing documents. Only documents written afterwards carry its values. ### Changes that are refused Some properties decide how already indexed values were stored, and changing them would make the existing data unreadable or wrong. A change to any of these is refused with `409 incompatible_schema`, naming the field: - the field's type - single-valued versus multi-valued - a vector's `dims`, `metric` or `truncate_dims` - a decimal's `scale` - the `analyzer` or `normalizer` - the `index` mode or `column` ```json { "type": "https://warpsearch.io/docs/errors/incompatible_schema", "title": "Conflict", "status": 409, "code": "incompatible_schema", "detail": "field \"year\": the type cannot change from int to string; add a new field (or a variant) and reindex instead", "request_id": "7d1c1a3e0f9b4c2e" } ``` Adding fields and templates is always allowed, and so are changes that apply only to data written later: `ann` settings and `long_terms`. Vector storage encoding is not configurable through the schema API. The same checks apply when you change a schema through the Elasticsearch-compatible `_mapping` endpoint or the Solr Schema API. To change a field, add a new field (or a [variant](#variants)) with the definition you want, reindex your source data into it, and switch your queries over. Removing a field and reusing its name does not erase the old indexed values. ## Templates and suffixes A template is a definition that applies to every field whose name ends with the template name. A template named `_attr` covers `shoe_attr`, `socket_attr` and any other field ending in `_attr`, including fields that appear later, with no schema update. Use templates for fields you cannot list in advance, such as per-category product attributes. ```json { "fields": {"productname": {"parent": "_t"}}, "templates": {"_attr": "string"} } ``` With that schema, this document needs nothing more: ```json {"id": "shoe1", "productname": "Trail shoes", "shoe_width_attr": "wide"} ``` An explicit field definition always wins over a template. A definition can name a template as its `parent` to inherit its properties, as `productname` does above. ### Built-in suffixes These templates exist in every collection, so a field named with one of these suffixes is typed without any declaration: | Suffix | Type and behavior | |---|---| | `_t` | `text`. Unicode word splitting, case and accent folding, English possessive removal and English stemming. The general-purpose text field. | | `_u` | `text`. Unicode words, case and accent sensitive. | | `_un` | `text`. Unicode words with case folding; accents kept, no stemming. | | `_w` | `text`. Split on whitespace, case and accent sensitive. | | `_wl` | `text`. Split on whitespace and lowercased. | | `_s` | `string`, indexed for exact match, with a column for sorting and facets. | | `_sc` | `string`, column only (no term index). | | `_ss`, `_ssc` | Multi-valued forms of `_s` and `_sc`. | | `_i`, `_is` | `int`, single or multi-valued. | | `_f`, `_fs` | `float`, single or multi-valued. | | `_d`, `_ds` | `double`, single or multi-valued. | | `_dt`, `_dts` | `date`, single or multi-valued. | | `_b`, `_bs` | `boolean`, single or multi-valued. | | `_ip`, `_ips` | `ip`, single or multi-valued. | | `_name`, `_names` | A names field: searchable by word, with the whole value kept for facets and sorting (a `text` field with a `string` variant). `_names` is multi-valued. | | `_p`, `_ps` | `geo_point` with a points index (`index: "range"`), single or multi-valued. | | `_v`, `_vs` | `vector`, single or multi-valued. Stored only, until a field definition gives it a `metric`. | ```json {"id": "b1", "title_t": "The Way of Kings", "genre_s": "fantasy", "year_i": 2010, "tags_ss": ["epic", "fantasy"], "published_dt": "2010-08-31"} ``` These suffixes are a WarpSearch convention, not a feature of Elasticsearch, OpenSearch or Solr, although the compatible APIs accept documents that use them. Text fields are stored in the default compressed group, and numeric suffix fields are column-backed without a points index; define the field and set `index: "range"` when range queries must be fast. ## Variants A variant is another way of indexing a field's value. You send the value once, under the field's name, and the schema indexes it in as many configurations as you list: by word and as a whole value, with and without stemming, forward and reversed, or at two vector sizes. Each variant is its own index named `__