elasticsearch使用

创建索引

PUT wuzk_user

返回acknowledged为true表示操作成功

elasticsearch使用_第1张图片

查询刚刚创建的索引

GET wuzk_user

elasticsearch使用_第2张图片

插入一条数据,put后面的含义

wuzk_user/_doc/1:索引/类型/ID

PUT wuzk_user/_doc/1
{
  "id": 1,
  "name": "wuzk",
  "age": 23,
  "gender": "男",
  "remark": "一个热爱学习的LOL玩家"

elasticsearch使用_第3张图片

 批量插入

PUT wuzk_user/_bulk
{"index":{"_index":"wuzk_user","_id":2}}
{"id": 2,"name": "亚索","age": 18,"gender": "男","remark":"且随疾风前行,身后亦须留心"}
{"index":{"_index":"wuzk_user","_id":3}}
{"id": 3,"name": "墨菲特","age": 28,"gender": "男","remark": "俺也是从石头里蹦出来的"}
{"index":{"_index":"wuzk_user","_id":4}}
{"id": 4,"name": "猴子","age": 20,"gender": "男","remark": "取经路上,俺老孙听到最多的一句话就是三师弟的话:大师兄,师父和二师兄又被妖怪抓走了"}
{"index":{"_index":"wuzk_user","_id":5}}
{"id": 5,"name": "盖伦","age": 18,"gender": "男","remark": "人在塔在"}
{"index":{"_index":"wuzk_user","_id":6}}
{"id": 6,"name": "瑞兹","age": 18,"gender": "男","remark": "灾难始终慢我一步"}
{"index":{"_index":"wuzk_user","_id":7}}
{"id": 7,"name": "嘉文四世","age": 18,"gender": "男","remark": "德玛西亚"}
{"index":{"_index":"wuzk_user","_id":8}}
{"id": 8,"name": "安妮","age": 18,"gender": "女","remark": "火焰,是我最喜欢的颜色"}
{"index":{"_index":"wuzk_user","_id":9}}
{"id": 9,"name": "机器人","age": 18,"gender": "男","remark": ".........."}
{"index":{"_index":"wuzk_user","_id":10}}
{"id": 10,"name": "女枪","age": 18,"gender": "女","remark": "我有两把枪,一把叫射,一把叫啊..."}

elasticsearch使用_第4张图片

 查询全部

GET wuzk_user/_search
{
  "query": {
    "match_all": {}
  }

elasticsearch使用_第5张图片

match查询性别是女的

GET wuzk_user/_search
{
  "query": {
    "match": {
      "gender": "女"
    }
  }
}

elasticsearch使用_第6张图片

 query_string查询

GET wuzk_user/_search
{
  "query": {
    "query_string": {
      "default_field": "gender",
      "query": "女"
    }
  }
}

term查询

GET wuzk_user/_search
{
  "query": {
    "term": {
      "gender": {
        "value": "女"
      }
    }
  }
}

match模糊查询

GET wuzk_user/_search
{
  "query": {
    "match": {
      "remark": "一"
    }
  }
}

elasticsearch使用_第7张图片

query_string模糊查询

GET wuzk_user/_search
{
  "query": {
    "query_string": {
      "default_field": "remark",
      "query": "是"
    }
  }
}

elasticsearch使用_第8张图片

 multi_match多字段查询

GET wuzk_user/_search
{
  "query": {
    "multi_match": {
      "query": "机 菲 文四",
      "fields": ["name","remark"]
    }
  }
}

elasticsearch使用_第9张图片

你可能感兴趣的:(elasticsearch,大数据)