批量删除一些数据

根据查询条件删除某些数据

POST patientinfo/_delete_by_query?scroll_size=5000
{
  "query": {
    "term": {
      "dataLevel": {
        "value": "2"
      }
    }
  }
}

分析分词

GET /patientinfo/_analyze
{
"text":"单核细胞HLA-DR",
"tokenizer":"ik_max_word"
}

统计去重数据

GET patientinfo/_search
{
  "aggs": {
    "count":{
      "cardinality": {
        "field": "empiId"
      }
    }
  }
}

百分比

每个病种中10-20年龄所占的比例

GET patientinfo/_search?_source=patAge
{
  "aggs": {
    "NAME": {
      "terms": {
        "field": "patientDiseaseInfo.diseaseName",
        "size": 10
      },
      "aggs": {
        "match_p":{
          "filter": {
            "range": {
              "patAge": {
                "gte": 10,
                "lte": 20
              }
            }
          }
        },
        "match_percent": {
          "bucket_script": {
            "buckets_path": {
              "totalCount":"_count",
              "matchCount":"match_p._count"
            },
            "script": "params.matchCount/params.totalCount * 100"
          }
        }
      }
    }
  },
  "from": 0,
  "size": 1
}

查询

分组后查询每组最新的数据