使用NEST从ElasticSearch中的插件设置analyzer
我的第一个SO帖子! 我正在尝试为字符串字段设置一个Stempel分析器(波兰语的ES分析器)。我可以通过PUT请求来完成:使用NEST从ElasticSearch中的插件设置analyzer,nest,
elasticsearch-net,Nest,
elasticsearch Net,我的第一个SO帖子! 我正在尝试为字符串字段设置一个Stempel分析器(波兰语的ES分析器)。我可以通过PUT请求来完成: { "doc": { "_source": { "enabled": false }, "properties": { "file": { "type": "attachment", **"analyzer": "polish"**,
{
"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")
))));
它工作正常,因此.NET正在检测此分析器。
我使用的是ES 2.1.1&
NEST 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; }
}
您可能应该检查上的兼容性矩阵
Nest 1.7.1与ES 2.1.1不兼容请注意:Nest 2.x已发布。非常感谢您的帮助!将尽快使用它,厌倦了创建JSON请求
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; }
}