0
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"))
                                           ));

4

1 回答 1

0

由于附件是嵌套字段,因此您需要使用嵌套查询

.Nested(c => c
    .Path(p => p.attachments)
    .InnerHits = new InnerHits {},
    .Query(q =>
           q.Match(mq => mq.Field("attachments.attachment.content").Query("b"))
))

作为回应,您需要从内部点击中读取对象

于 2020-03-13T08:48:19.163 回答