Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version upgrade from 8.16.3 to 8.17.0 broken nested mapping type #8445

Closed
nadzk opened this issue Jan 9, 2025 · 2 comments
Closed

Version upgrade from 8.16.3 to 8.17.0 broken nested mapping type #8445

nadzk opened this issue Jan 9, 2025 · 2 comments
Labels
8.x Relates to 8.x client version Category: Bug

Comments

@nadzk
Copy link

nadzk commented Jan 9, 2025

In version 8.17.0 mapping for nested fields are not recognized, the "type": "nested" is missing hence queries fail. But when downgrading back to 8.16.3 everything works as expected

Index created in 8.16.3:
{ "test-index": { "aliases": {}, "mappings": { "properties": { "branches": { "type": "nested", "properties": { "id": { "type": "long" }, "services": { "type": "nested", "properties": { "id": { "type": "long" }, "name": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } } } } } } } }, "settings": { "index": { "creation_date": "1705197654049", "number_of_shards": "1", "number_of_replicas": "1", "uuid": "vMprJ3AHSperrvC_sbOvcw", "version": { "created": "7050099" }, "provided_name": "business-index" } } } }

Index created in 8.17.0:
{ "test-index": { "aliases": {}, "mappings": { "properties": { "branches": { "properties": { "id": { "type": "long" }, "services": { "properties": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "id": { "type": "long" }, "name": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, } } } } } }, "settings": { "index": { "routing": { "allocation": { "include": { "_tier_preference": "data_content" } } }, "number_of_shards": "1", "provided_name": "test-index", "creation_date": "1736434041031", "number_of_replicas": "1", "uuid": "5SBIB0pjRpe17hVyiTz0kg", "version": { "created": "8080299" } } } } }

Index Mapping:

`
protected override TypeMappingDescriptor ConfigureMappings(TypeMappingDescriptor descriptor)
{
return descriptor
.Properties(p => p
.Nested(n => n.Branches, nd => nd.Properties(np => np
.Keyword(k => k.Branches.First().Id)
.Nested(nn => nn.Branches.First().Services, nnd => nnd.Properties(nnp => nnp
.LongNumber(k => k.Branches.First().Services.First().Id)
.Text(t => t.Branches.First().Services.First().Name))
)))
);
}

var createResponse = await _client.Indices.CreateAsync(IndexName, descriptor => descriptor
.Mappings(mapping => ConfigureMappings(mapping)));
`

Elastic.Clients.Elasticsearch version: 8.17.0

Elasticsearch version: 8.8.2

.NET runtime version : 8.0.11

@nadzk nadzk added 8.x Relates to 8.x client version Category: Bug labels Jan 9, 2025
@flobernd
Copy link
Member

flobernd commented Jan 9, 2025

Hi @nadzk,

I'm not able to reproduce this. The following example:

var mapping = new TypeMappingDescriptor<X>() // Your code uses a non-generic version here which does not exists!?
    .Properties(p => p
        .Nested(n => n.Branches, nd => nd.Properties(np => np
            .Keyword(k => k.Branches.First().Id)
            .Nested(nn => nn.Branches.First().Services, nnd => nnd.Properties(nnp => nnp
                .LongNumber(k => k.Branches.First().Services.First().Id)
                .Text(t => t.Branches.First().Services.First().Name))
            ))));

await client.Indices.CreateAsync<X>("new_idx", d => d.Mappings(mapping));

public class X
{
    public Y[] Branches { get; set; } = default!;
}

public class Y
{
    public string Id { get; set; } = default!;
    public Z[] Services { get; set; } = default!;
}

public class Z
{
    public string Id { get; set; } = default!;
    public string Name { get; set; } = default!;
}

Produces this valid request:

# Request:
{
  "mappings": {
    "properties": {
      "branches": {
        "properties": {
          "id": {
            "type": "keyword"
          },
          "services": {
            "properties": {
              "id": {
                "type": "long"
              },
              "name": {
                "type": "text"
              }
            },
            "type": "nested"
          }
        },
        "type": "nested"
      }
    }
  }
}

Could you please post a complete reproducer, including the data classes (redacted to only contain the required properties).

@nadzk
Copy link
Author

nadzk commented Jan 9, 2025

Weirdly I can't reproduce this issue now either, will close the issue. Thanks for the prompt response though. 👍🏻

@nadzk nadzk closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x Relates to 8.x client version Category: Bug
Projects
None yet
Development

No branches or pull requests

2 participants