首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ElasticSearch中NEST插件的设置分析器

ElasticSearch中NEST插件的设置分析器
EN

Stack Overflow用户
提问于 2016-01-27 13:45:49
回答 1查看 325关注 0票数 2

我的第一篇如此帖子!我试图为string字段设置一个Stempel Analyzer (用于波兰语言的ES分析器)。我可以通过提交请求做到这一点:

代码语言:javascript
运行
复制
{
   "doc": {
      "_source": {
         "enabled": false
      },
      "properties": {
         "file": {
            "type": "attachment",
            **"analyzer": "polish"**,
            "fields": {
               "content": {
                  "type": "string",
                  "term_vector": "with_positions_offsets"
               }
            }
         }
      }
   }
}

而且效果很好。试图通过巢穴做同样的事情。

代码语言:javascript
运行
复制
 [ElasticProperty(Name = "_content", TermVector = TermVectorOption.WithPositionsOffsets, Analyzer = "polish")]
 public string Content { get; set; }

也不起作用:

代码语言:javascript
运行
复制
            client.CreateIndex(index, b => b.AddMapping<DocInES>(m => m
            .MapFromAttributes()
            .Properties(props => props
                .String(s => s
                    .Name(p => p.File.Content)
                    .Analyzer("polish")
                     ))));

当我用

代码语言:javascript
运行
复制
var result = client.Analyze(a => a.Index("doc").Analyzer("polish").Text("...text..."));

它工作得很好,所以.NET正在检测这个分析器。我用的是ES 2.1.1。& NEST 1.7.1

编辑:据我观察,NEST似乎不是在映射在.NET中创建的附件类的属性,而是做文档类的Map属性

代码语言:javascript
运行
复制
[ElasticType(Name = "docInES")]
public class DocInES {
    public int InstitutionId { get; set;}
    public int DocumentId { get; set; }
    [ElasticProperty(Store = true, Analyzer = "polish")]
    public string Title { get; set; }

    [ElasticProperty(Type = FieldType.Attachment)]
    public Attachment File { get; set; }

}

但不是附件类:

代码语言:javascript
运行
复制
public class Attachment {
    [ElasticProperty(Name = "content2", Store = true)]
    public string Content { get; set; }

    [ElasticProperty(Name = "content_type2")]
    public string ContentType { get; set; }

    [ElasticProperty(Name = "name2", Analyzer = "english")]
    public string Name { get; set; }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-29 08:18:37

您可能应该检查Github上的兼容性矩阵。

Nest 1.7.1与ES 2.1.1不兼容

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35039086

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档