Skip to content

BulkAll does not honor [JsonIgnore] attribute #8163

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
kylepmanuel opened this issue Apr 24, 2024 · 2 comments
Closed

BulkAll does not honor [JsonIgnore] attribute #8163

kylepmanuel opened this issue Apr 24, 2024 · 2 comments
Labels
8.x Relates to a 8.x client version Category: Not an issue

Comments

@kylepmanuel
Copy link

Elastic.Clients.Elasticsearch version: 8.13.9

Elasticsearch version: 8.13.0

.NET runtime version: net6.0

Operating system version: win11

Description of the problem including expected versus actual behavior:
When indexing individual documents using IndexAsync<TDocument> everything is as expected. When using BulkAll<T>, additional properties are being added to the index metadata that have the attribute [JsonIgnore].

Steps to reproduce:

  1. Create a class that includes a property with the [JsonIgnore] attribute from from System.Text.Json.Serialization
  2. Index a single instance using IndexAsync
  3. Index multiple instances using BulkAll and observe the ignored properties now in the index metadata

Expected behavior
BulkAll should honor the [JsonIgnore] attribute on a property.

@flobernd
Copy link
Member

Hi @kylepmanuel,

I think this might be an error on your side.

Please double check you are using the JsonIgnoreAttribute from the System.Text.Json namespace and not the one from e.g. Newtonsoft.Json. They are called the same and during my test right now I made the same mistake because the old using was still in the header of my test project 🙂

Please let me know, if that solved your issue. In my local tests I was not able to reproduce the problem after using the correct attribute.

@kylepmanuel
Copy link
Author

After reviewing our implementation, I think our issue was something unrelated. We rolled our own AutoMap<T> and the index was created as expected using Client.Indices.CreateAsync<T>. IndexAsync did not update the index metadata "mappings", but BulkAll did with properties our auto map ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x Relates to a 8.x client version Category: Not an issue
Projects
None yet
Development

No branches or pull requests

2 participants