# Error indexing data in Elasticsearch

**URL:** <https://discuss.elastic.co/t/error-indexing-data-in-elasticsearch/297416>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [February 16, 2022, 8:58pm UTC](https://discuss.elastic.co/t/error-indexing-data-in-elasticsearch/297416 "2022-02-16T20:58:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matheus26](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Matheus26](https://discuss.elastic.co/u/Matheus26)\
**Post date:** [February 16, 2022, 8:58pm UTC](https://discuss.elastic.co/t/error-indexing-data-in-elasticsearch/297416/1 "2022-02-16T20:58:57Z")

</div>

Hi,  
I'm trying to index datas in Elasticsearch, but I'm getting an error.  
I'm using the latest Nest release (7.17.0) in C#  
The error is "Failed to serialize anonymous type".  
This error message is from an exception after use Nest's IndexMany method.  
I indexed some data, but at some point this error occurs.

Does anyone have any idea why this happens?  
Thanks.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 17, 2022, 12:51am UTC](https://discuss.elastic.co/t/error-indexing-data-in-elasticsearch/297416/2 "2022-02-17T00:51:04Z")

</div>

Welcome to our community! 😃

I can't directly help with this, but it'd be useful for someone that knows this language if you could show the entire error, and the relevant code section.

---

<div class="post-metadata">

**Author:** ![Matheus26](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Matheus26](https://discuss.elastic.co/u/Matheus26)\
**Post date:** [February 17, 2022, 1:55pm UTC](https://discuss.elastic.co/t/error-indexing-data-in-elasticsearch/297416/3 "2022-02-17T13:55:50Z")

</div>

Thanks for the answer!

The entire error is below:

Failed to serialize anonymous type: Nest.BulkIndexOperation`1[AdsHelpers.AdELSMiscItemBase]. The type defines the following properties: 'Document' of type AdsHelpers.AdELSMiscItemBase 'Percolate' of type System.String 'Pipeline' of type System.String 'IfSequenceNumber' of type System.Nullable`1[System.Int64]  
'IfPrimaryTerm' of type System.Nullable`1[System.Int64] 'Id' of type Nest.Id 'Index' of type Nest.IndexName 'RetriesOnConflict' of type System.Nullable`1[System.Int32]  
'Routing' of type Nest.Routing  
'Version' of type System.Nullable`1[System.Int64] 'VersionType' of type System.Nullable`1[Elasticsearch.Net.VersionType]

I have a method that fills some objects of AdsHelpers.AdELSMiscItemBase and index in Elasticsearch.  
The following is how I initialize the client and use the method that inserts multiple records in Elasticsearch.

```auto
ConnectionSettings settings = new ConnectionSettings(new Uri(ElasticsearchUri));
settings.DefaultIndex(indexName);

ElasticClient client = new ElasticClient(settings);

BulkResponse response = client.IndexMany(ads);

```

The variable "ads" is the list with some AdELSMiscItemBase.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 17, 2022, 1:56pm UTC](https://discuss.elastic.co/t/error-indexing-data-in-elasticsearch/297416/4 "2022-03-17T13:56:38Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
