# Error when adding vector data with Elastic.Clients.Elasticsearch version 9.0.0

**URL:** <https://discuss.elastic.co/t/error-when-adding-vector-data-with-elastic-clients-elasticsearch-version-9-0-0/379388>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [June 21, 2025, 11:17pm UTC](https://discuss.elastic.co/t/error-when-adding-vector-data-with-elastic-clients-elasticsearch-version-9-0-0/379388 "2025-06-21T23:17:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppworks](https://avatars.discourse-cdn.com/v4/letter/p/cc9497/32.png) [@ppworks](https://discuss.elastic.co/u/ppworks)\
**Post date:** [June 21, 2025, 11:17pm UTC](https://discuss.elastic.co/t/error-when-adding-vector-data-with-elastic-clients-elasticsearch-version-9-0-0/379388/1 "2025-06-21T23:17:37Z")

</div>

The code is as follows:

```auto
/// <summary>
/// Create an index
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected async void Button1_Click(object sender, EventArgs e)
{
    // Connection configuration
    var settings = new ElasticsearchClientSettings(new Uri("http://localhost:9200"))
       .Authentication(new BasicAuthentication("elastic", "Trq8 ********** +gX"))
       .DefaultIndex("vector_demo");
    var client = new ElasticsearchClient(settings);

    // 1. Create an index (with a 384-dimensional vector field)
    var createIndexResponse = await client.Indices.CreateAsync("vector_demo", c => c
       .Mappings(m => m
           .Properties(p => p
               .Keyword("id")
               .Text("title")
               .DenseVector("embedding", v => v
                   .Dims(384)
                   .Index(true)
                   .Similarity(DenseVectorSimilarity.Cosine)
                   .IndexOptions(o => o
                       .Type(DenseVectorIndexOptionsType.Hnsw)
                       .M(16)
                       .EfConstruction(100)
                   )
               )
           )
       );

    if (!createIndexResponse.IsValidResponse)
    {
        Response.Write($"Failed to create index: {createIndexResponse.DebugInformation}");
    }
}

/// <summary>
/// Add data
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected async void Button2_Click(object sender, EventArgs e)
{
    // Connection configuration
    var settings = new ElasticsearchClientSettings(new Uri("http://localhost:9200"))
      .Authentication(new BasicAuthentication("elastic", "Trq8w *********** +gX"))
      .DefaultIndex("vector_demo");

    var client = new ElasticsearchClient(settings);

    // 2. Add sample data
    var documents = new List<object>
{
    new {
        id = "doc1",
        title = "Introduction to Artificial Intelligence",
        embedding = GenerateRandomVector(384)
    },
    new {
        id = "doc2",
        title = "Machine Learning Algorithms",
        embedding = GenerateRandomVector(384)
    },
    new {
        id = "doc3",
        title = "Applications of Natural Language Processing",
        embedding = GenerateRandomVector(384)
    }
};

    // 3. Bulk index documents (after correction, no need to wrap with BulkOperation anymore)
    var bulkOperations = new List<IBulkOperation>();
    foreach (var doc in documents)
    {
        var indexOperation = new BulkIndexOperation<object>(doc)
        {
            Index = "vector_demo"
        };
        bulkOperations.Add(indexOperation);
    }

    var bulkRequest = new BulkRequest
    {
        Operations = bulkOperations
    };

    var bulkResponse = await client.BulkAsync(bulkRequest);
    // When executing the above line, an exception will be thrown: Elastic.Transport.UnexpectedTransportException: “The 'G' format combined with a precision is not supported. The unsupported member type is located on type 'System.Single'. Path: $.embedding.”
    NotSupportedException: The 'G' format combined with a precision is not supported.
}

/// <summary>
/// Generate a random vector (for example only)
/// </summary>
/// <param name="dimensions"></param>
/// <returns></returns>
float[] GenerateRandomVector(int dimensions)
{
    var random = new Random();
    var vector = new float[dimensions];

    for (int i = 0; i < dimensions; i++)
    {
        vector[i] = (float)random.NextDouble();
    }

    // Normalization (optional, depending on your vector generation method)
    var magnitude = Math.Sqrt(vector.Sum(v => v * v));
    for (int i = 0; i < dimensions; i++)
    {
        vector[i] /= (float)magnitude;
    }

    return vector;
}

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 22, 2025, 2:07pm UTC](https://discuss.elastic.co/t/error-when-adding-vector-data-with-elastic-clients-elasticsearch-version-9-0-0/379388/2 "2025-06-22T14:07:36Z")

</div>

Welcome!

What is the error?

---

<div class="post-metadata">

**Author:** ![flobernd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flobernd/32/124877_2.png) [@flobernd](https://discuss.elastic.co/u/flobernd)\
**Post date:** [June 23, 2025, 7:30am UTC](https://discuss.elastic.co/t/error-when-adding-vector-data-with-elastic-clients-elasticsearch-version-9-0-0/379388/3 "2025-06-23T07:30:21Z")

</div>

Hi @ppworks

from your code snippet, it seems like the exception is as follows:

> When executing the above line, an exception will be thrown: Elastic.Transport.UnexpectedTransportException: “The 'G' format combined with a precision is not supported. The unsupported member type is located on type 'System.Single'. Path: $.embedding.”  
> NotSupportedException: The 'G' format combined with a precision is not supported.  
> }

I just tested the exact same code and for me the test data is correctly indexed.

What .NET SDK are you using and what is the TFM for your application?

---

<div class="post-metadata">

**Author:** ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)\
**Post date:** [June 23, 2025, 8:50am UTC](https://discuss.elastic.co/t/error-when-adding-vector-data-with-elastic-clients-elasticsearch-version-9-0-0/379388/4 "2025-06-23T08:50:31Z")

</div>

> [@flobernd](#):
>
> What .NET SDK are you using and what is the for your application?

Maybe you missed a word Florian. What is the ???? for his/her application!?

---

<div class="post-metadata">

**Author:** ![flobernd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flobernd/32/124877_2.png) [@flobernd](https://discuss.elastic.co/u/flobernd)\
**Post date:** [June 23, 2025, 2:58pm UTC](https://discuss.elastic.co/t/error-when-adding-vector-data-with-elastic-clients-elasticsearch-version-9-0-0/379388/5 "2025-06-23T14:58:08Z")

</div>

Thanks! I edited my post 🙂

---

<div class="post-metadata">

**Author:** ![onyxmaster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/onyxmaster/32/144910_2.png) [@onyxmaster](https://discuss.elastic.co/u/onyxmaster)\
**Post date:** [September 4, 2025, 10:11pm UTC](https://discuss.elastic.co/t/error-when-adding-vector-data-with-elastic-clients-elasticsearch-version-9-0-0/379388/6 "2025-09-04T22:11:50Z")

</div>

The System.Memory shim (even the latest version version 4.6.3) for .NET Framework, [does not support](https://github.com/dotnet/maintenance-packages/blob/cf8d27a145c74a6632671f4d62575fe9c23b0b3c/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Float.cs#L79) specifying custom precision for serialized data.

Given that ES driver tries to pass there a G17 format string, it crashes. This leads to the inability of driver to serialize floating-point numbers, when driver is running under .NET Framework.

Reported as [Broken floating-point source serialization for .NET Framework · Issue #8696 · elastic/elasticsearch-net · GitHub](https://github.com/elastic/elasticsearch-net/issues/8696)
