How to disable camel casing Elasticsearch field names in NEST?

前端 未结 2 1507
粉色の甜心
粉色の甜心 2020-12-15 21:07

By default, NEST will camel case object and property names when sending an object to Elasticsearch for indexing. How can camel casing field names be disabled in NEST for Ela

相关标签:
2条回答
  • 2020-12-15 21:13

    ConnectionSettings.SetDefaultPropertyNameInferrer() is what you're looking for. This method accepts a function that takes a property name and applies a transformation to it. The function is then called on each of your properties before requests are sent to Elasticsearch.

    If you want to keep your property names untouched, then you can do this:

    settings.SetDefaultPropertyNameInferrer(p => p)

    p => p here just simply being a function that takes a string (your property name) and returns the same string unmodified.

    0 讨论(0)
  • 2020-12-15 21:19

    In version 2.5.0 it's:

    settings.DefaultFieldNameInferrer(p => p)
    
    0 讨论(0)
提交回复
热议问题