Class Mail
{
public string MailID {get;set;}
[nested]
public List<Attachment> attachments {get;set;}
}
Class Attachment
{
public int AttachmentID {get;set;}
public string Data {get; set;}
[nested]
public Nest.attachment {get;set;}
}
上面是我的索引结构,Ingest Pipeline数据索引正确,但当尝试搜索附件内容时,它会返回带有所有附件的孔附件对象以及实际搜索附件。在结果中我只想要具有搜索结果的附件
以下是我的查询
var response1 = elasticClient.Search<Mail>(s => s
.Index(indexName)
.Query(q =>
q.Match(mq => mq.Field("attachments.attachment.content").Query("b"))
));
由于附件是嵌套字段,因此需要使用嵌套查询
.Nested(c => c
.Path(p => p.attachments)
.InnerHits = new InnerHits {},
.Query(q =>
q.Match(mq => mq.Field("attachments.attachment.content").Query("b"))
))
作为回应,你需要从内部命中读取对象