Skip to content

Elasticsearch .NET 8+ deserialization problem when elastic fields have specific names #8788

@JamesPScottPharm3r

Description

@JamesPScottPharm3r

If I have a field named: field_123 in an index, and I query that index with the .NET Elastic library (using GetAsync, SearchAsync etc.) any fields that end in this numeric type of format are not deserialized.

E.g.

PUT /test-index
{
"mappings": {
"dynamic": "strict",
"properties": {
"id": {
"type": "keyword"
},
"string_5": {
"type": "keyword"
}
}
}
}

POST /test-index/_doc/docone
{
"id": "docone",
"string_5": "this value for test"
}

Now using the Elastic client retrieve docone into a POCO that looks like this:

public class PocoExample {
public required string Id { get; set; }
public string? String5 { get; set;
}

You'll see that String5 is not Deserialized properly and is null.

Note that if the field name is "string_value5" it would be fine... its just when any field naming ends with numbers only... after _ or perhaps other characters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions