c# - Elasticsearch NEST创建不区分大小写的索引

标签 c# elasticsearch nest elasticsearch-5

如何在NEST中创建将不区分大小写与TermQuery进行比较的索引?

我尝试了以下方法(以及许多类似方法),但是我的TermQuery只返回区分大小写的匹配结果。

Client.CreateIndex("my_index", (c) => c
    .Settings(s => s
        .Analysis(an => an
            .Analyzers(ans => ans
                .Custom("analyzer_keyword", cu => cu
                    .Tokenizer("keyword")
                    .Filters("lowercase")
                 )
                .Custom("analyzer_term", cu => cu
                    .Tokenizer("term")
                    .Filters("lowercase")
                 )
            )
        )
    )
);

最佳答案

我不知道如何使用NEST进行此操作,但我知道一件事-您有两种选择:

  • 您可以指定default分析器

  • 要么
  • ,您需要,将analyzer_keywordanalyzer_term用于文档的字段。

  • 因为您的代码现在只指定了一些自定义分析器,所以没有在任何地方使用。
    看看specifying an index time analyzer:

    At index time, if no analyzer has been specified, it looks for an analyzer in the index settings called default. Failing that, it defaults to using the standard analyzer.


    specifying a search time analyzer:

    The analyzer to use to search a particular field is determined by looking for:

    • An analyzer specified in the query itself.
    • The search_analyzer mapping parameter.
    • The analyzer mapping parameter.
    • An analyzer in the index settings called default_search.
    • An analyzer in the index settings called default.
    • The standard analyzer.

    关于c# - Elasticsearch NEST创建不区分大小写的索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48788329/

    相关文章:

    c# - 对 MongoDb 和 Entity Framework 的抽象

    elasticsearch - 使用ElasticSearch可以根据相关性过滤出结果吗?

    json - 从Elasticsearch 6迁移到7时的Json问题

    c# - 从 NEST 调度 Update() 到 Elasticsearch.NET 失败

    C# LINQ 使用 where 子句连接 2 个表

    c# - Xamarin - 清除 ListView 选择

    c# - 适用于 Windows Phone 的 Facebook SDK : InvalidOperationException: Operation is not valid due to the current state of the object

    ruby-on-rails - 合并 Elasticsearch 查询和过滤器无法正常工作

    elasticsearch - elasticsearch nest似乎不支持功能分数中的提升因子

    c# - 带过滤器的 Elasticsearch 建议