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

In the fluent index mapping using the Keyword property descriptor lambda method for a list of strings throws an exception #8121

Open
kylepmanuel opened this issue Apr 12, 2024 · 0 comments
Labels
8.x Relates to 8.x client version Area: Helpers Category: Bug

Comments

@kylepmanuel
Copy link

Elastic.Clients.Elasticsearch version: 8.13.5

Elasticsearch version: 8.13.0

.NET runtime version: net6.0

Operating system version: win11

Description of the problem including expected versus actual behavior:
Using the fluent index mapping, the Keyword method signature that accepts a lambda (Expression<Func<TDocument, object>>) will throw an error on a list of strings.

Error:

Elastic.Transport.UnexpectedTransportException: 'Sequence contains no elements'

Steps to reproduce:
Using this test class:

    public class TestDoc
    {
       public IList<string> Tags { get; set; } = new List<string>();
    }

Attempt to create an index:

    var r = await Client.Indices.CreateAsync<TestDoc>("testdoc", c => c
      .Mappings(m => m
        .Properties(p => p
            .Text(t => t.Tags, c => c
              .Fields(f => f
                .Keyword(kk => kk, cc => cc
                  .IgnoreAbove(256)
                )
              )
            )
          )
        )
    );

Expected behavior
Should produce this mapping without error:

    "tags": {
      "type": "text",
      "fields": {
        "keyword": {
          "ignore_above": 256,
          "type": "keyword"
        }
      }
    }

Original question asked in the Elastic forum: Creating index for list of strings

Workaround:

    .Fields(f => f
            .Keyword("keyword", cc => cc
                .IgnoreAbove(256)
            )
        )
@kylepmanuel kylepmanuel added 8.x Relates to 8.x client version Category: Bug labels Apr 12, 2024
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 Area: Helpers Category: Bug
Projects
None yet
Development

No branches or pull requests

2 participants