# Convert dense vector to float

**URL:** <https://discuss.elastic.co/t/convert-dense-vector-to-float/374412>\
**Category:** Elasticsearch\
**Tags:** vector-search\
**Created:** [February 12, 2025, 9:43am UTC](https://discuss.elastic.co/t/convert-dense-vector-to-float/374412 "2025-02-12T09:43:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aviel\_Bashari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviel_bashari/32/92464_2.png) [@Aviel\_Bashari](https://discuss.elastic.co/u/Aviel_Bashari)\
**Post date:** [February 12, 2025, 9:43am UTC](https://discuss.elastic.co/t/convert-dense-vector-to-float/374412/1 "2025-02-12T09:43:47Z")

</div>

Hi im using ELK stack V 8.13.3  
i having an issue in my index:  
i dont know why but I pushed 8 vectors and the mapper set them as dense\_vector(no activity from my side to set this type was done)  
now this 8 vectors can change the size and I got mapper error.  
my goal is to change them into float.  
i tried to create new index with new float mapping to problematic fields and reindex the data to new index excluding the dense vector(currently the data in dense\_vector can be descarted)  
but I got always 2 parameters with the same name but different types in new index:  
1.float  
2.dense vector  
my devtoolcode:

```auto
PUT /rf_equipment_data_simple_new_2025
{
  "mappings": {
    "properties": {
      "ES_FLATNESS_AVERAGE_RES": { 
        "type": "nested",
        "properties": { "values": { "type": "float" } }
      },
      "SEMASK_AVERAGE_SPECTRUM_OFR_TRACE": { 
        "type": "nested",
        "properties": { "values": { "type": "float" } }
      },
      "SEMASK_MAX_SPECTRUM_TRACE": { 
        "type": "nested",
        "properties": { "values": { "type": "float" } }
      },
      "TRACE_SE_MASK_AVG_RBW_100": { 
        "type": "nested",
        "properties": { "values": { "type": "float" } }
      },
      "TRACE_SE_MASK_AVG_RBW_1000": { 
        "type": "nested",
        "properties": { "values": { "type": "float" } }
      },
      "SEMASK_AVERAGE_SPECTRUM_TRACE": { 
        "type": "nested",
        "properties": { "values": { "type": "float" } }
      },
      "TRACE_SE_MASK_MAX_RBW_100": { 
        "type": "nested",
        "properties": { "values": { "type": "float" } }
      },
      "TRACE_SE_MASK_MAX_RBW_1000": { 
        "type": "nested",
        "properties": { "values": { "type": "float" } }
      }
    }
  }
}

```

MAPPING SHOWS ONLY FLOATS:

```auto
GET rf_equipment_data_simple_new_2025/_mapping

```

REINDEX EXCLUDE DENSE\_VECTOR

```auto
POST _reindex?wait_for_completion=false
{
  "source": {
    "index": ["rf_equipment_data-000001", "rf_equipment_data-000002", "rf_equipment_data-000003"],  
    "size": 1000
  },
  "dest": {
    "index": "rf_equipment_data_simple_new_2025"
  },
  "script": {
    "source": """
    // Remove all fields that were previously dense_vector
    def keysToRemove = [];
    
    for (entry in ctx._source.entrySet()) {
      // Check if the field was a dense_vector (by checking for an object with a "dims" key)
      if (entry.getValue() instanceof Map && entry.getValue().containsKey("dims")) {
        keysToRemove.add(entry.getKey());
      }
    }

    // Remove all identified dense_vector fields
    for (key in keysToRemove) {
      ctx._source.remove(key);
    }

    // Add a success message to confirm reindexing
    ctx._source["reindex_status"] = "SUCCESS";
    """
  }
}

```

any help please?  
in addition I want my current ILM will be applied to new index, is it possible?

---

<div class="post-metadata">

**Author:** ![Justin\_Castilla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_castilla/32/135379_2.png) [@Justin\_Castilla](https://discuss.elastic.co/u/Justin_Castilla)\
**Post date:** [February 12, 2025, 8:32pm UTC](https://discuss.elastic.co/t/convert-dense-vector-to-float/374412/2 "2025-02-12T20:32:06Z")

</div>

Hello, just a couple things off the top of my head:

- Are you able to reindex the dense\_vectors to an array of floats with a new name? Then reindex to a third, moving over only the floats?
- Are you able to explicitly remove the dense\_vectors by field name in your script?
- Check to make sure all of the dense vectors you want to convert and remove are of the exact same nested structure. There may be discrepancies in how they're stored

You can see if changing your dynamic mapping in your reindex helps. [Here's the doc](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html)

And yes, you can enact your ILM in your new index, like so:

```json
PUT /rf_equipment_data_simple_new_2025
{
  "settings": {
    "index.lifecycle.name": "your_ilm_policy_name",
    "index.lifecycle.rollover_alias": "your_alias_if_applicable"
  },
  "mappings": {
    "dynamic": "strict", #if you want to try this out
    "properties": {
      "ES_FLATNESS_AVERAGE_RES": { 
        "type": "nested",
        "properties": { "values": { "type": "float" } }
      }, ...
}

```

You can also create a index\_template that adds your ILM to all ensuing indexes.

These are just some ideas without reproduction efforts. Let me know how it goes.

---

<div class="post-metadata">

**Author:** ![Aviel\_Bashari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviel_bashari/32/92464_2.png) [@Aviel\_Bashari](https://discuss.elastic.co/u/Aviel_Bashari)\
**Post date:** [February 13, 2025, 11:36am UTC](https://discuss.elastic.co/t/convert-dense-vector-to-float/374412/3 "2025-02-13T11:36:13Z")

</div>

Hi @Justin_Castilla and thanks for the quick response!  
regarding bullet #1:  
how should I do it? I tried multiple times and when the source index has dense\_vector -\> it moves on to the newly generated one.

regarding bullet #1:  
already tried -\> same result.

By the way, I realized that on my ELK stack version, each vector above the size of 128 will be automatically inserted as a dense vector, right?
