2

我的第一个 SO 帖子!我正在尝试为字符串字段设置 Stempel Analyzer(波兰语的 ES 分析器)。我可以通过 PUT 请求来做到这一点:

{
   "doc": {
      "_source": {
         "enabled": false
      },
      "properties": {
         "file": {
            "type": "attachment",
            **"analyzer": "polish"**,
            "fields": {
               "content": {
                  "type": "string",
                  "term_vector": "with_positions_offsets"
               }
            }
         }
      }
   }
}

它工作正常。试图通过 NEST 做同样的事情。

 [ElasticProperty(Name = "_content", TermVector = TermVectorOption.WithPositionsOffsets, Analyzer = "polish")]
 public string Content { get; set; }

不工作也不行:

            client.CreateIndex(index, b => b.AddMapping<DocInES>(m => m
            .MapFromAttributes()
            .Properties(props => props
                .String(s => s
                    .Name(p => p.File.Content)
                    .Analyzer("polish")
                     ))));

当我使用

var result = client.Analyze(a => a.Index("doc").Analyzer("polish").Text("...text..."));

它工作正常,因此 .NET 正在检测此分析器。我正在使用 ES 2.1.1。& 巢 1.7.1

编辑:从我的检查来看,NEST 似乎没有对在.NET 中创建的附件类的属性进行映射。它确实映射文档类的属性

[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; }

}

但不是附件类:

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; }
}
4

1 回答 1

0

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

Nest 1.7.1 与 ES 2.1.1 不兼容

于 2016-01-29T08:18:37.770 回答