ES语句

1.新建结构化索引

PUT index_test_2018-07-05

{

  "settings": {

    "number_of_shards": 3,

    "number_of_replicas": 1

  },

  "mappings": {

    "test_table": {

      "properties": {

        "name": {

          "type": "text"

        },

        "age": {

          "type": "integer"

        },

        "date": {

          "type": "date",

          "format": "yyyy-MM-dd HH:mm:ss|| yyy-MM-dd||epoch_millis"

        }

      }

    }

  }

}

2.index_test_2018-07-05索引下新增test_table表数据,id=1

PUT /index_test_2018-07-05/test_table/1

{

  "name":"测试员1",

  "age":23,

  "date":"2018-07-05 14:00:00"

}

3.查询语句

Get index_test_2018-07-05/test_table/1

查询 index_test_2018-07-05索引下所有数据

GET /index_test_2018-07-05/test_table

{

  "query": {

    "match_all": {

    }

  }

}

按字段name模糊查询

GET /index_test_2018-07-05/test_table

{

  "query": {

    "match": {

      "name":"测"

    }

  }

}

--查所有

GET emr/JHMR_FILE_INDEX/_search

GET _search

{

  "query": {

    "match_all": {}

  }

}

--结构查询

get _search

{

  "query":{

    "match":{

      "type":"医疗统计月报"

    }

  }

}

get health_statistics_report/_search

{

  "query":{

    "bool": {

      "must": [

        {

        "match": {

          "type": "医疗统计月报"

        }

        }

      ]

    }

  }

}

--查询指定日期

{

  "query": {

    "range": {

      "startedOn": {

        "lt": "2018-01-01T00:00:00",

        "gte": "2017-01-01T00:00:00"

      }

    }

  }

}



--创建index

PUT health_statistics_report

{

  "settings": {

    "number_of_shards": 3,

    "number_of_replicas": 1

  },

  "mappings": {

    "V_ShowInvokingRecord": {

      "properties": {

"type": {

          "type": "text"

        },

        "dataValue": {

          "type": "text"

        },

        "dataCount": {

          "type": "integer"

        },

        "createDate": {

          "type": "date",

          "format": "yyyy-MM-dd HH:mm:ss|| yyy-MM-dd||epoch_millis"

        }

      }

    }

  }

}

--查询所有

get health_statistics_report/_search

get health_statistics_report/HealthStatisticsReport/2018-07-10

get health_statistics_report/HealthStatisticsReport/2018-07-10?_source=true

get health_statistics_report/HealthStatisticsReport/_search

--JSON完整的请求体,结构化查询(DSL)

get _search

{

  "query":{

    "match":{ --match:分词查询 match_phrase:分词精确查询 term:完全匹配,不进行分词器分析

      "type":"医疗统计月报"   

    }

  }

}

--删除index(包含type)

DELETE health_statistics_report

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容