我正在使用 elasticsearc 2.3.3 和 Nest 2.3.2,我需要创建索引。需要将属性映射到类文件中添加的属性。
public class IndexDocument
{
[Number(Store = true)]
public long Id { get; set; }
[String(Store = true, Index = FieldIndexOption.Analyzed, TermVector = TermVectorOption.WithPositionsOffsets)]
public string Title { get; set; }
public Attachment File { get; set; }
[String(Store = true, Index = FieldIndexOption.Analyzed)]
public string DocumentType { get; set; }
[String(Store = true, Index = FieldIndexOption.NotAnalyzed)]
public string DocLocation { get; set; }
[String(Store = true, Index = FieldIndexOption.Analyzed)]
public DateTime LastModifiedDate { get; set; }
}
public class Attachment
{
public Attachment()
{
}
[String(Name = "_content_length", Store = true, Index = FieldIndexOption.Analyzed)]
public long ContentLength { get; set; }
[String(Store = true, Index = FieldIndexOption.Analyzed, TermVector = TermVectorOption.WithPositionsOffsets, Name = "_content")]
public string Content { get; set; }
}
另外我想在文件字段中添加一个完成建议。我是这个弹性搜索的新手。有人可以帮忙吗?
我创建了如下的附件索引。如何使用此附加完成建议和词干分析器代码?
this.client.CreateIndex("mydocs", c => c.Mappings(mp => mp.Map<IndexDocument>
(m => m.Properties(ps => ps.Attachment
(a => a.Name(o => o.File)
.TitleField(t => t.Name(x => x.Title).TermVector(TermVectorOption.WithPositionsOffsets))
)))));