Set analyzers for _all field with NEST

时光总嘲笑我的痴心妄想 提交于 2019-12-13 05:07:27

问题


As described in the _all field Elasticsearch Documentation.

The _all fields allows for store, term_vector and analyzer (with specific index_analyzer and search_analyzer) to be set.

Is there a way to specify the index_analyzer and search_analyzer attributes on the _all field for a mapping with NEST? Specifically, I would like to be able to set the following for my index:

 {
     "model": {
        "_all": { 
             "index_analyzer": "nGram_analyzer",
             "search_analyzer": "whitespace_analyzer"
        }

       ...
  }

I did not see anything that would allow for this in the Fluent Mappings. Can I set this manually if not via Fluent Mapping?


回答1:


Starting from NEST 1.0 you can now do this:

var result = this._client.Map<ElasticsearchProject>(m => m
    .AllField(a=>a
        .Enabled() 
        .IndexAnalyzer("nGram_analyzer")
        .SearchAnalyzer("whitespace_analyzer")
        .TermVector(TermVectorOption.with_positions_offsets)
    )
    ...
    ...


来源:https://stackoverflow.com/questions/22920421/set-analyzers-for-all-field-with-nest

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!