# Elastic.Clients fails indexing my data type with an IntegerRange (integer\_range) in it even though I'm using a template mapping

**URL:** <https://discuss.elastic.co/t/elastic-clients-fails-indexing-my-data-type-with-an-integerrange-integer-range-in-it-even-though-im-using-a-template-mapping/341513>\
**Category:** Kibana\
**Created:** [August 23, 2023, 7:23pm UTC](https://discuss.elastic.co/t/elastic-clients-fails-indexing-my-data-type-with-an-integerrange-integer-range-in-it-even-though-im-using-a-template-mapping/341513 "2023-08-23T19:23:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathemaphysics](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathemaphysics/32/120925_2.png) [@Mathemaphysics](https://discuss.elastic.co/u/Mathemaphysics)\
**Post date:** [August 23, 2023, 7:23pm UTC](https://discuss.elastic.co/t/elastic-clients-fails-indexing-my-data-type-with-an-integerrange-integer-range-in-it-even-though-im-using-a-template-mapping/341513/1 "2023-08-23T19:23:40Z")

</div>

The problem was caused by the use of the `JsonPropertyName` decorator on my data structure properties.

> [@Mathemaphysics](#):
>
> I'm trying to use the `Elastic.Clients` library to index documents with a range in them (specifically an `integer_range` named `ItemIndexRange`, serialized as `item_index_range`). I'm implementing the class using the ES native type inside, `IntegerRange`, but it seems to ignore its own type and claims on indexing that "failed to parse field [item\_index\_range] of type [integer\_range] in document ... Preview of field's value: '11865'".
> 
> Why would it think that an `integer_range` consists only of the first entry (`GreaterThanOrEqualTo`)?
> 
> What boggles my mind even more is that I'm inserting this document into an index which matches a template that _knows_ that this field name is an `integer_range`. So why would I need to specify mapping at all on the C# end?
> 
> Any possible direction would be helpful. Thanks.
> 
> I'm using the latest 8.X version of ES. I'll find the specific number if needed.

---

<div class="post-metadata">

**Author:** ![Mathemaphysics](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathemaphysics/32/120925_2.png) [@Mathemaphysics](https://discuss.elastic.co/u/Mathemaphysics)\
**Post date:** [August 24, 2023, 2:07pm UTC](https://discuss.elastic.co/t/elastic-clients-fails-indexing-my-data-type-with-an-integerrange-integer-range-in-it-even-though-im-using-a-template-mapping/341513/2 "2023-08-24T14:07:30Z")

</div>

Never mind this didn't work either. The bulk indexing worked but it completely failed to serialize the names the way I had told it to in my data class using `DataMember` decorators.

I can't seem to find any documentation at all for 8.9's serialization. For example, my data members in a class are named `variableName` and I indicate them to be serialized as `variable_name` using the `DataMember` decorator like the Elastic.Clients library seems to do everywhere.

It turns out this doesn't work at all. It just ignores all my `DataMember` decorators and puts it as is, destroying my index template for the new index. What am I missing?

---

<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:** [September 21, 2023, 2:07pm UTC](https://discuss.elastic.co/t/elastic-clients-fails-indexing-my-data-type-with-an-integerrange-integer-range-in-it-even-though-im-using-a-template-mapping/341513/3 "2023-09-21T14:07:34Z")

</div>

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