Error while building a k-NN index from model using Lucene engine

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

OpenSearch - 2.8.0
Server OS - Oracle Linux Server 7.9

Describe the issue:

I’m trying to build a k-NN index from a model using Lucene engine. I’m getting Validation error while using the k-NN plugin’s Train API. Can you please share if this error is expected with Lucene engine and it only works for nmslib/faiss engines. I faced this issue while following the below k-NN plugin documentation.

API used:

# Building a k-NN index from a model
PUT /train-index
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 0
  },
  "mappings": {
    "properties": {
      "train-field": {
        "type": "knn_vector",
        "dimension": 4
      }
    }
  }
}

POST _bulk
{ "index": { "_index": "train-index", "_id": "1" } }
{ "train-field": [1.5, 5.5, 4.5, 6.4]}
{ "index": { "_index": "train-index", "_id": "2" } }
{ "train-field": [2.5, 3.5, 5.6, 6.7]}
{ "index": { "_index": "train-index", "_id": "3" } }
{ "train-field": [4.5, 5.5, 6.7, 3.7]}
{ "index": { "_index": "train-index", "_id": "4" } }
{ "train-field": [1.5, 5.5, 4.5, 6.4]}


POST /_plugins/_knn/models/my-model/_train
{
  "training_index": "train-index",
  "training_field": "train-field",
  "dimension": 4,
  "description": "My model description",
  "method": {
    "name": "hnsw",
    "engine": "lucene"
  }
}

Error in the last API used:
{
  "error": {
    "root_cause": [
      {
        "type": "action_request_validation_exception",
        "reason": "Validation Failed: 1: Method does not require training.;"
      }
    ],
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: Method does not require training.;"
  },
  "status": 400
}

Relevant Logs or Screenshots:

Creating an index with model is only supported with Faiss engine and not supported with Lucene engine.

Also with faiss, you can use model with IVF ,IVF-PQ and HNSW-PQ algorithms of Faiss only

@amank

1 Like

Thank you @Navneet for providing the clarification.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.