[英]Query inner records in ElasticSearch Nest C#
I have structure like this: 我有这样的结构:
public class OuterResource
{
public int Id { get; set; }
[Nested]
public List<InnerResource> InnerResources { get; set; }
}
public class InnerResource
{
public int Id { get; set; }
public int OuterResourceId { get; set; }
public int Value { get; set; }
}
Inner records are stored as lists inside outer records. 内部记录存储为外部记录中的列表。 I want to query inner records, giving specified outer resource id and value to filter inner records.
我想查询内部记录,提供指定的外部资源ID和值以过滤内部记录。
How to do it in C# Nest? 如何在C#Nest中进行操作? Can't figure it out from documentation.
无法从文档中找出答案。
请尝试这个。
objforOuterResource.InnerResources.Where(x => x.Id == 5);
.Query<OuterResource>.Nested(n => n
.Path(p => p.InnerResources)
.Query(qq => qq
.Terms(t => t.Fields(fi => fi.InnerResources.First().OuterResourceId ).Terms(value))
)
)
Should work. 应该管用。 Note the .First is applied to all the array (=list)
注意.First应用于所有数组(= list)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.