alexklibisz/elastiknn

Can't create vector fields by Elasticsearch index templates

livelxw opened this issue · 2 comments

Describe the bug
When I create an es index template for creating vector fields and creating the docs, it returns failed to parse.

Expected behavior
The docs should be created successfully with the vector fields.

Environment (please complete the following information):

  • Elastiknn version: 7.14.1.2

To Reproduce
Steps to reproduce the behavior:

  1. Create an index template
PUT _index_template/test_template
{
  "index_patterns": [
    "test"
  ],
  "template": {
    "settings": {
      "number_of_shards": 9,
      "number_of_replicas": 1,
      "elastiknn": true
    },
    "mappings": {
      "dynamic_templates": [
        {
          "vector_as_cosine_lsh": {
            "match_mapping_type": "double",
            "path_match": "vectors.*",
            "mapping": {
              "type": "elastiknn_dense_float_vector",
              "elastiknn": {
                "dims": 2,
                "model": "lsh",
                "similarity": "cosine",
                "L": 99,
                "k": 1
              }
            }
          }
        }
      ]
    }
  }
}
  1. Create a doc
POST test/_update/123
{
  "doc": {
    "vectors.bbb": [
      0.1,
      0.1
    ]
  },
  "upsert": {}
}
  1. First time see
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "123",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

but no data in doc
4. If create again, see

{
  "error" : {
    "root_cause" : [
      {
        "type" : "",
        "reason" : ": C[A]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse",
    "caused_by" : {
      "type" : "",
      "reason" : ": C[A]"
    }
  },
  "status" : 400
}

Hey, thanks for reporting this. I've never used index templates. I probably won't have time to look into this for at least a couple weeks. In the meantime, see the developer-guide.md if you are interested in trying to fix it.

If you have any stack traces from the elasticsearch node, that would also be very helpful.