# How to set field names to lowercase while creating an index using NEST?

**URL:** <https://discuss.elastic.co/t/how-to-set-field-names-to-lowercase-while-creating-an-index-using-nest/67756>\
**Category:** Elasticsearch\
**Created:** [December 1, 2016, 12:14pm UTC](https://discuss.elastic.co/t/how-to-set-field-names-to-lowercase-while-creating-an-index-using-nest/67756 "2016-12-01T12:14:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhkx](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hhkx](https://discuss.elastic.co/u/hhkx)\
**Post date:** [December 1, 2016, 12:14pm UTC](https://discuss.elastic.co/t/how-to-set-field-names-to-lowercase-while-creating-an-index-using-nest/67756/1 "2016-12-01T12:14:40Z")

</div>

Hi,

I have been creating a repository with c# for elastic search.

Get function is like that:

```
    var response = client.Search<TEntity>(s => s
    .From(0)
    .Size(10)
    .Index(_indexName)
    .Type(_typeName)
    .Query(q => q.MatchAll() && query)  
    );

```

Create function is below:

```
    _client.Index(entity, s => s
        .Index(_indexName)
        .Refresh());

```

When I run this code it creates a document, there is nothing with it. However, because I am using entitys and their names, when I pass the entity name through elastic search, it make the first character of type name lower. (e.g, User\_Id =\> user\_Id)

What I need to do is making all characters lower while creating the index and querying them with .ToLower().

So my question is, what is the best way to set elasticsearch case-insensitive for fields?

Thanks for your help in advance.

PS: I believe calling entity.Name.ToLower() on create() is not a good solution.

---

<div class="post-metadata">

**Author:** ![hhkx](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hhkx](https://discuss.elastic.co/u/hhkx)\
**Post date:** [December 1, 2016, 2:12pm UTC](https://discuss.elastic.co/t/how-to-set-field-names-to-lowercase-while-creating-an-index-using-nest/67756/2 "2016-12-01T14:12:46Z")

</div>

I have found some settings on this link: [http://stackoverflow.com/questions/27282865/how-to-disable-camel-casing-elasticsearch-field-names-in-nest](http://stackoverflow.com/questions/27282865/how-to-disable-camel-casing-elasticsearch-field-names-in-nest)

Basically it is saying to add

`settings.SetDefaultPropertyNameInferrer(p => p)`

`settings.DefaultFieldNameInferrer(p => p) for (NEST 5.0)`

to connectionsettings.

---

<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:** [December 29, 2016, 2:12pm UTC](https://discuss.elastic.co/t/how-to-set-field-names-to-lowercase-while-creating-an-index-using-nest/67756/3 "2016-12-29T14:12:51Z")

</div>

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