Set analyzers for _all field with NEST

2019-09-01 01: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?

标签: nest
1条回答
你好瞎i
2楼-- · 2019-09-01 02:08

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)
    )
    ...
    ...
查看更多
登录 后发表回答