竞争无处不在,青春永不言败!专业撸代码,副业修bug

Talk is cheap , show me the code!



ElasticSearch

ES 是开源分布式高可用灵活的搜索引擎 基于 Lucene

正确的顺序:

ES安装x-pack
ES启动
设置密码
Kibana 安装 x-pack
修改Kibana的配置文件
启动Kibana

ELK ElasticSearch(核心) Logstash(采集?) Kibana(可视化)

常见CURD操作 PUT GET POST DELETE

PUT person/doc/1
{
  "name":"frank",
  "age":18,
  "gender":"Male",
  "DOB":"19900101"
}

PUT person/doc/2
{
  "name":"tom",
  "age":19,
  "gender":"Male",
  "DOB":"19880203"
}

GET person/doc/_search

GET person/doc/_search?q=age:19

POST person/doc/1/_update
{
  "doc":{
  "age":16
  }
}

DELETE person

POST person/doc/_delete_by_query?q=name:frank


GET person/doc/_search
{"query":{
  "match":{
    "age":18
  }
}}

GET person/doc/_search
{"query":{
  "match":{
    "name":"frank tom"
  }
}}

# 排序
GET person/doc/_search
{
  "query": {
    "match_all": {}
  }
  , "sort": [
    {
      "age": {
        "order": "desc"
      }
    }
  ]
}

分页
GET person/doc/_search
{
  "query": {
    "match_all": {}
  }
  , "sort": [
    {
      "age": {
        "order": "desc"
      }
    }
  ],
  "from": 0,
  "size": 1
}

GET person/doc/_search
{
  "query": {
    "bool": {
      "should": [
        {"match": {
          "name": "frank"
         }
        },
        {"match": {
          "age": 19
        }}
      ]
    }
  },
  "sort": [
    {
      "age": {
        "order": "desc"
      }
    }
  ],
  "from": 0,
  "size": 2
}


GET person/doc/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "name": "frank"
          }
        },
        {"match":{
          "gender":"Male"
        }}
      ],
      "must": [
        {"match": {
          "age": "18"
        }}
      ]
    }
  }
}

GET person/doc/_search
{
  "query": {
    "bool": {
     "filter": {
       "range": {
         "age": {
           "gte": 18,
           "lte": 20
         }
       }
     } 
    }
  }
}
posted @ 2020-01-15 10:26  云雾散人  阅读(190)  评论(0编辑  收藏  举报

Your attitude not your aptitude will determine your altitude!

如果有来生,一个人去远行,看不同的风景,感受生命的活力!