【发布时间】:2015-06-04 06:35:55
【问题描述】:
我最近开始使用弹性搜索,我正在尝试使用 mapper-attachment 插件索引 pdf 文档,索引时我遇到错误值不能为空参数名称:索引,有人可以帮助解决这个问题..
这是索引的代码:
static void Main(string[] args)
{
var connectionSettings = new ConnectionSettings(new Uri("http://localhost:9200/"));
var elasticClient = new ElasticClient(connectionSettings);
elasticClient.CreateIndex("pdf-index", c => c.AddMapping<Document>(m => m.MapFromAttributes()));
var attachment = new Attachment
{
Content = Convert.ToBase64String(File.ReadAllBytes("test.pdf")),
ContentType = "application/pdf",
Name = "test.pdf"
};
var doc = new Document()
{
Id = 1,
Title = "test",
File = attachment
};
elasticClient.Index(doc);
}
public class Attachment
{
[ElasticProperty(Name = "_content")]
public string Content { get; set; }
[ElasticProperty(Name = "_content_type")]
public string ContentType { get; set; }
[ElasticProperty(Name = "_name")]
public string Name { get; set; }
}
public class Document
{
public int Id { get; set; }
public string Title { get; set; }
[ElasticProperty(Type = FieldType.Attachment, TermVector = TermVectorOption.WithPositionsOffsets, Store = true)]
public Attachment File { get; set; }
}
【问题讨论】:
标签: elasticsearch attachment nest elasticsearch-plugin