nest - 在 Elasticsearch.net、Nest 上使用 Stop Filter 和 stopword_path

标签 nest

我如何将停止过滤器...与stopword_path一起使用? 我可以在 postman 中使用停止过滤器

这是我的代码。

    "analysis" : {
    "analyzer" : {
        "ilhee_Custom" : {
            "type": "custom",
                "tokenizer" : "whitespace",
                "filter" : ["lowercase", "my_stoplist"]
                 }
            },
    "filter" : {
         "my_stoplist" : {
            "type" : "stop",
                "stopwords_path" : "stopword_list.txt",
                    "remove_trailing" : true
                    }
                }
            }
    }

我找到答案了!!是吗?

     var stoplist = new StopTokenFilterDescriptor();
        stoplist.StopWordsPath(@"\stopword_list.txt");   
       var createIndexResponse = client.CreateIndex("ilhee", c => c
        .Settings(s => s
         .Analysis(a => a
          .Analyzers(ad => ad       
           // give the custom analyzer a name
           .Custom("ilhee_Custom", ca => ca
            .Tokenizer("standard")
            .Filters("lowercase", "stop", "standard", "snowball","my_stoplist")
           )
          )
          .TokenFilters(s1=>s1
          .UserDefined("my_stoplist",stoplist))
            )       
         )
    );

最佳答案

那会起作用的。您还可以使用 TokenFiltersDescriptor

上的 Stop() 方法
var createIndexResponse = client.CreateIndex("ilhee", c => c
    .Settings(s => s
        .Analysis(a => a
            .Analyzers(ad => ad
                // give the custom analyzer a name
                .Custom("ilhee_Custom", ca => ca
                    .Tokenizer("standard")
                    .Filters("lowercase", "stop", "standard", "snowball", "my_stoplist")
                )
            )
            .TokenFilters(s1 => s1
                .Stop("my_stoplist", tf => tf
                    .StopWordsPath("stopword_list.txt")
                )
            )
        )   
    )
);

Path is relative to config location or an absolute path.

关于nest - 在 Elasticsearch.net、Nest 上使用 Stop Filter 和 stopword_path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37915092/

相关文章:

c# - 通过三个调用在Elastic Search中使用索引策略更新文档效率不高

c# - 如何使用NEST elasticsearch批量插入Json?

C# NEST Elasticsearch自定义过滤器结构(tokenize)

.net - 如何通过NEST搜索ElasticSearch并过滤结果以查找自定义属性上的不同条目

c# - 如何使用NEST API搜索数据?

c# - 将 NEST (Elasticsearch) 搜索结果转换为数据集 - C#

NEST ElasticClient C# 批量插入集合

elasticsearch - 在ElasticSearch 6中使用过滤器按嵌套对象聚合

elasticsearch - _id在Elasticsearch中未自动生成

elasticsearch - nest:如何使用UpdateByQuery()?