ES语法(简)

1.上编写到怎样安装部署elk,这篇记录怎样简单使用。以便于后期复习使用。

2.登录localhost:5601进入开发者模式。

3.初学担心没有数据可以自己PUT数据比较直观的学习语法。这里可以用网上的开源数据。比如shakespeare.json accounts.json等数据源

4.导入数据在服务器上导入用curl -H "Content-Type: application/json"  -XPOST 'localhost:9200/shak/account/_bulk?pretty' --data-binary "@/home/jx/shakespeare.json"  导入失败之类

一般是因为没有加-H条件。

5.查找

5.1一般查找    GET   /shakespeare

5.2条件查找   

GET   /shakespeare/_search
{
"query": { "match": { "text_entry": "No more the thirsty entrance of this soil" } }, "sort": [ { "line_id": "desc" } ] }

5.3过滤查找

GET /shakespeare/_search
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "text_entry": "like"
        }
      },
      "filter": {
        "range": {
          "line_id": {
            "gt": "50"
          }
        }
      }
    }
  }
}

注意:要理解数据字段的意思和数据库的思维一样

5.4全文检索某个字段包含某个关键字

GET /shakespeare/_search
{
  "query": {
    "match": {
      "text_entry": "echo"
    }
  }
}

5.5全文短语检索

GET /shakespeare/_search
{
  "query": {
    "match_phrase": {
      "text_entry": "of the"
    }
  }
}

5.6

GET /shakespeare/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "text_entry": "like"
          }
        }
      ],
      "should": [
        {
          "match": {
            "speaker": "ORLANDO"
          }
        }
      ],
      "must_not": [
        {
          "match": {
            "gt": "10000"
          }
        }
      ],
      "minimum_should_match": 1
    }
  }
}

注意:操作都在开发工具里完成。

 5.7 基础语法

查看数据状态:GET    localhost:9200/_cat/indices

查看某个数据状态: GET localhost:9200/shakespeare

查看es状态: GET localhost:9200

查看所有索引 : GET 10.2.15.232:9200/_cat

posted @ 2020-03-26 10:11  升级打怪之路  阅读(1153)  评论(0编辑  收藏  举报