0
我最近開始使用彈性搜索,我試圖索引一個PDF文檔與映射器附件插件,當索引我打錯誤值不能是空參數名:索引,可有人在解決這個幫助..彈性搜索mapper-attachments,NEST-在索引投擲錯誤
這裏是索引代碼:我猜你忘了你的彈性搜索添加默認索引
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; }
}