Elasticsearch/kibana随笔

#ik分词器两种方式
GET _analyze
{
  "analyzer": "ik_smart",
  "text": "超级喜欢张小明"
}

GET _analyze
{
  "analyzer": "ik_max_word",
  "text": "超级喜欢张小明"
}

#索引的基本操作
#添加
PUT /test1/type1/1
{
  "name":"张三",
  "age":3
}

#建索引和字段
PUT /test2
{
  "mappings": {
    "properties": {
      "name":{
        "type": "text"
      },
      "age":{
        "type": "long"
      },"birthday":{
        "type": "date"
      }
    }
  }
}

GET test2
GET test1

GET _cat/indices?v

#修改
#以前的方法,PUT如果不传递值就会覆盖
PUT /test1/type1/1
{
  "name":"张三13",
  "age":3
}

#现在的方式
POST /test1/type1/1/_update
{
  "doc":{
    "name":"张三14"
  }
}


#删除索引
DELETE /test2
 

 

PUT /test3/type1/4
{
  "name":"张三",
  "age":23,
  "desc":"测试4",
  "tags":["插画1","阳光","虎"]
}

#查询
GET /test3/type1/1
GET /test3/type1/_search?q=age:39

GET /test3/type1/_search
{
  "query": {
    "match": {
      "desc": "测试"
    }
  },
  "_source": ["name","desc"],
  "sort": [
    {
      "age": {
        "order": "desc"
      }
    }
  ],
  "from": 0, "size": 2
}

#多条件查询
GET /test3/type1/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "name": "张三"
          }
        },{
          "match": {
            "age": "23"
          }
        }
      ]
    }
  }
}

#查询索引的全部文档
GET molv_index/_doc/_search
{
    "query": {"match_all": {}}
}

must 类似and

should 类似or

must_not 类似 not

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值