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 query