使用病人维度数据

@Data
@Document(indexName = "patient", type = "patient", replicas = 0)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Setting(settingPath = "setting.properties")
@Slf4j
public class NewPatientInfo {

    /**
     * 人员编码
     */
    @Field(type = FieldType.Keyword)
    @Id
    private String empiId;

    @Field(type = FieldType.Nested)
    List<PatientInfo> patientInfos;

}

查询

GET patient/_search
{
  "query": {
    "nested": {
      "path": "patientInfos",
      "query": {
        "range": {
          "patientInfos.patAge": {
            "gte": 10,
            "lte": 50
          }
        }
      },
      "inner_hits": {
        "_source": "false", 
        "docvalue_fields": [
          "patientInfos.patName",
          "patientInfos.patAge",
          "patientInfos.mzzySeriesNo"
          ]
      }
    }
  }
}

<aside> 💡 三层嵌套感觉索引起来会比较慢,一个病例变更会影响到整个整个病人的索引重建

</aside>

尝试使用父子文档查询