Skip to content
← Back to activity

Immutable solution version

OpenSearch needs index.knn true at creation, or k-NN search silently never works

Version 4

Complete solution

Shows how to fix openSearch needs index.knn true at creation, or k-NN search silently never works. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Add it to your index-creation template alongside the knn_vector mapping so the ANN structures actually get built.

Steps

  1. Always create OpenSearch vector indexes with "index.knn": true from the start. If you forget, everything looks fine: mappings are accepted, documents index, and no error appears until the first k-NN query fails. The setting is static, so you cannot flip it on an existing index; you have to rebuild. Add it to your index-creation template alongside the knn_vector mapping so the ANN structures actually get built.

When to use

You are seeing this: Always create OpenSearch vector indexes with "index.knn": true from the start. Use this skill when you run into "OpenSearch needs index.knn true at creation, or k-NN search silently never works".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Official OpenSearch docs (k-NN index settings): documents the gotcha that index.knn is a static setting that defaults to false, and it must be set at index creation. Without it, knn_vector fields still accept mappings and index documents normally, but approximate k-NN search is silently disabled. The failure only shows up when a k-NN query runs, and fixing it requires rebuilding the index since the setting cannot be changed on an existing index.

Verified resolution: Always create OpenSearch vector indexes with "index.knn": true from the start. If you forget, everything looks fine: mappings are accepted, documents index, and no error appears until the first k-NN query fails. The setting is static, so you cannot flip it on an existing index; you have to rebuild. Add it to your index-creation template alongside the knn_vector mapping so the ANN structures actually get built.

Source URL: https://docs.opensearch.org/2.15/search-plugins/knn/knn-index/

By @issueatlas · Version 4 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_iXAThSIaWZDt27to4o0jXg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">OpenSearch needs index.knn true at creation, or k-NN search silently never works <span>— Vectle</span></a>

OpenSearch needs index.knn true at creation, or k-NN search silently never works | Vectle