弹性搜索建议类型由关键字分析器打破

时间:2016-03-22 15:17:33

标签: .net elasticsearch nest completion

CustomAnalyzer productIndexAnalyzer = new CustomAnalyzer
        {
            Tokenizer = "standard",
            Filter = new List<string> { TURKISH_LOWERCASE, "apostrophe", "asciifolding", ENGRAM_FILTER }
        };

        IIndicesOperationResponse indicesOperationResponse = _elasticClientFactory.Create().CreateIndex(SearchConstants.ProductIndex, c => c
            .Analysis(analysis => analysis
                .TokenFilters(tf => tf
                    .Add(TURKISH_LOWERCASE, turkishLowercaseTokenFilter)
                    .Add(ENGRAM_FILTER, edgeNgramTokenFilter))
                .Analyzers(a => a
                    .Add(PRODUCT_SEARCH_ANALYZER, productSearchAnalyzer)
                    .Add(PRODUCT_INDEX_ANALYZER, productIndexAnalyzer)
        ))
            .AddMapping<Product>(m => m.MapFromAttributes().Properties(props => props
                .Completion(s => s
                    .Name(p => p.Suggest)
                    .MaxInputLength(20)
                    .Payloads()
                    .PreservePositionIncrements()
                    .PreserveSeparators()
                )
            ))
            );

在弹性上嵌套客户端映射结果:

"suggest": {
              "type": "completion",
              "analyzer": "simple",
              "payloads": true,
              "preserve_separators": true,
              "preserve_position_increments": true,
              "max_input_length": 20
           },

productIndexAnalyzer已更改,我添加了 TURKISH_KEYWORDS 分析器 我将结果索引为以下与客户端嵌套。设置为建议完成类型。

CustomAnalyzer productIndexAnalyzer = new CustomAnalyzer
        {
            Tokenizer = "standard",
            Filter = new List<string> { TURKISH_LOWERCASE, "apostrophe", "asciifolding", ENGRAM_FILTER, "turkish_keywords" }
        };

但是当我添加一个 TURKISH_KEYWORDS 分析器并且它是一个字符串时,它表明该类型是扭曲的。

在弹性上嵌套客户端映射结果:

"suggest": {
              "properties": {
                 "input": {
                    "type": "string"
                 },
                 "output": {
                    "type": "string"
                 },
                 "weight": {
                    "type": "long"
                 }
              }
           }

我使用的是NEST版本1.7.0和Elasticsearch版本1.7.3

0 个答案:

没有答案