【发布时间】:2019-07-20 14:52:35
【问题描述】:
我正在尝试对以下对象的索引执行搜索:
public class IndexedElement
{
public Guid Id { get; set; }
public long RowId { get; set; }
public IndexedElementType Type { get; set; }
public string Summary { get; set; }
public string Description { get; set; }
public IList<string> Tags { get; set; }
}
目的是通过摘要属性进行搜索,或者通过匹配标签集合中的任何字符串
我目前拥有的是这样的:
public IEnumerable<IndexedElement> Search(string description)
{
var query = GetClient().Search<IndexedElement>(s => s.From(0).Size(5)
.Query(
q => q.Term(p => p.Summary, description)
||
q.Nested(n => n.Path(p => p.Tags).Query(q2 => q2.Terms(t => t.Field(f => f.Tags).Terms(description))))
));
return query.Documents.ToList();
}
但是嵌套部分不起作用,我不知道我是否以正确的方式使用它,或者我必须为此找到另一个解决方案。
有什么想法吗?
提前谢谢大家
【问题讨论】:
标签: c# elasticsearch asp.net-core .net-core nest