Skip to content

Nested attribute #5170

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

Closed
DeepSkyJees opened this issue Dec 10, 2020 · 5 comments
Closed

Nested attribute #5170

DeepSkyJees opened this issue Dec 10, 2020 · 5 comments

Comments

@DeepSkyJees
Copy link

I want to use the Nested attribute, but it does not take effect, what should I do
image

image

@stevejgordon
Copy link
Contributor

@NigelYu How have you configured your mapping with AutoMap which is required to get the attribute mappings to take effect?

var createIndexResponse = _client.Indices.Create("grades", c => c
    .Map<Grade>(m => m.AutoMap())
);

@DeepSkyJees
Copy link
Author

DeepSkyJees commented Dec 11, 2020

@stevejgordon Yes, I used it, but the same does not work, this is my code

Grade grade = new Grade
{
                Id = "1",
                GradeName = "一年级",
                Persons = new List<Person> {
                    new Person
                    {
                        Id = "zhangshan",
                        FullName = "张珊"
                    },
                    new Person
                    {
                        Id = "lisi",
                        FullName = "李四"
                    }
                }
            };
            var elasticClient = GetElasticClient("http://192.168.20.15:9200/");
            var createIndexResponse = elasticClient.Indices.Create("nigel", c => c
                    .Map<Grade>(m => m.AutoMap())
            );
            elasticClient.Index<Grade>(grade,p=>p.Index("nigel"));

image

Is there any relevant example, can I refer to it?

@stevejgordon
Copy link
Contributor

I have a suspicion that the Store = true property is not valid for the mapping. Can you try removing that. When I repro locally, that causes the create index request to fail. Without it, it is mapped as nested.

@DeepSkyJees
Copy link
Author

Yes, I tried it, he works normally, thanks

@stevejgordon
Copy link
Contributor

That's good to here @NigelYu. Thanks for raising this as it highlights an issue with the attribute accepting that property. I'll open an issue to review that further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants