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


(Hasan) #1

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.


(Hasan) #2

I have found some settings on this link: 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.


(system) #3

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