How to create multiple dense vector field?

Im trying to create multiple dense vector field.
This is my mapping code:
{

"mappings": {
"properties": {
"ABSTRACT_vector": {
"type": "dense_vector",
"dims": 384
},
"BACKGROUND_vector": {
"type": "dense_vector",
"dims": 384
},
"METHODS_vector": {
"type": "dense_vector",
"dims": 384
},
"RESULTS_vector": {
"type": "dense_vector",
"dims": 384
},
"CONCLUSIONS_vector": {
"type": "dense_vector",
"dims": 384
},

However, Elasticsearch only creates one dense vector field, and the other dense vector field changed to float field automatically. How can I create multiple dense vector field?

I just tested this and it worked fine. What version of Elasticsearch are you using and what exactly are you seeing in the results?

I used dims: 4 just to simplify testing. It still works with higher dims.

{
  "mappings": {
    "properties": {
      "ABSTRACT_vector": {
        "type": "dense_vector",
        "dims": 4
      },
      "BACKGROUND_vector": {
        "type": "dense_vector",
        "dims": 4
      },
      "METHODS_vector": {
        "type": "dense_vector",
        "dims": 4
      },
      "RESULTS_vector": {
        "type": "dense_vector",
        "dims": 4
      },
      "CONCLUSIONS_vector": {
        "type": "dense_vector",
        "dims": 4
      }
    }
  }
}
POST multi_vectors/_doc
{
  "ABSTRACT_vector": [1, 2, 3, 4],
  "BACKGROUND_vector": [1, 2, 3, 4],
  "METHODS_vector": [1, 2, 3, 4],
  "RESULTS_vector": [1, 2, 3, 4],
  "CONCLUSIONS_vector": [1, 2, 3, 4]
}

^ And the mapping is still correct and searching worked just fine.

Here is my mapping result:

{
  "multi_vectors": {
    "aliases": {},
    "mappings": {
      "properties": {
        "ABSTRACT_vector": {
          "type": "dense_vector",
          "dims": 4
        },
        "BACKGROUND_vector": {
          "type": "dense_vector",
          "dims": 4
        },
        "CONCLUSIONS_vector": {
          "type": "dense_vector",
          "dims": 4
        },
        "METHODS_vector": {
          "type": "dense_vector",
          "dims": 4
        },
        "RESULTS_vector": {
          "type": "dense_vector",
          "dims": 4
        }
      }
    },
   ///settings...
  }
}
1 Like

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