使用Nest Client在Elasticsearch中加载完成字段 [英] Using Nest Client to load completion fields in Elasticsearch
问题描述
我想使用Nest将完成建议字段填充到索引中。在阅读了关于实施完成字段的 ElasticSearch博文后,我看到您可以具有以下属性: / p> 我假设将这些数据加载到索引中,我需要包括在我的搜索对象上包含以上字段的实体? 我能够通过创建几个类来终止完成字段,并按照 FluentMappingFullExample 单元测试,具体如下: 对于我的搜索类型实体,我创建一个名为建议的字段,并将其命名为CompletionField。 在使用dapper从db上加载实体后,我然后循环结果,并加载我的完成字段与我想要的适当的输入。然后我可以成功调用建议API并查询这些数据。我希望这有助于别人。 I would like to use Nest to populate the completion suggestion field into an index. After reading this ElasticSearch blog post about implementing a completion field I see you can have the following properties: I am assuming that to load this data into an index I need to include an entity on my search object that contains the above fields? I was able to finally load the completion field by creating several classes, and following the FluentMappingFullExample unit test, specifically the following part: For my search type entity, I created a field called suggest and made it of type CompletionField. After I loaded my entity from the db using dapper, I then looped over the results and loaded my completion field with the appropriate inputs that I wanted. I was then able to successfully call the suggest API and query on this data. I hope this helps someone else. 这篇关于使用Nest Client在Elasticsearch中加载完成字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
.Completion(s => s
.Name(p => p.Name.Suffix完成))
.IndexAnalyzer(standard)
.SearchAnalyzer(standard)
.MaxInputLength(20)
.Payloads()
.PreservePositionIncrements )
.PreserveSeparators()
)
public class CompletionField
{
public CompletionField()
{
Input = new List< string>();
}
public List< string>输入{get;组; }
// public string Output {get;组; }
public int Weight {get;组; }
public Payload Payload {get;组;
}
public class Payload
{
public int ID {get;组; }
}
.Completion(s=>s
.Name(p=>p.Name.Suffix("completion"))
.IndexAnalyzer("standard")
.SearchAnalyzer("standard")
.MaxInputLength(20)
.Payloads()
.PreservePositionIncrements()
.PreserveSeparators()
)
public class CompletionField
{
public CompletionField()
{
Input = new List<string>();
}
public List<string> Input { get; set; }
//public string Output { get; set; }
public int Weight { get; set; }
public Payload Payload { get; set; }
}
public class Payload
{
public int ID { get; set; }
}