本文介绍了使用NEST为_all字段设置分析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

_all字段Elasticsearch文档.

是否可以在_all字段上为使用NEST的映射指定index_analyzersearch_analyzer属性?具体来说,我希望能够为索引设置以下内容:

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"
        }

       ...
  }

在Fluent Mapping中,我看不到任何可以做到这一点的东西.如果不通过Fluent Mapping可以手动设置吗?

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.0开始,您现在可以执行以下操作:

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)
    )
    ...
    ...

这篇关于使用NEST为_all字段设置分析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 22:44