天天看點

elastic search head 基本用法

elastic search head 基本用法

es 安裝方法: http://knight-black-bob.iteye.com/blog/2259836

資源監控和叢集管理插件 

bin/plugin -install lukas-vlcek/bigdesk
http://192.168.13.140:9200/_plugin/bigdesk      

 資料查詢插件

bin/plugin -install mobz/elasticsearch-head
http://192.168.13.140:9200/_plugin/head/      

了解性:

   _index  類似 mysql中 database

   _type   類似  mysql 中 table

   _ id     類似  mysql 中 id

插入測試資料

使用 put   http://192.168.13.140:9200/baoyou/10120/17_2/

 {

  "token_id": 17,

  "type_id": 1,

  "tag_desc": "test data",

  "insert_time": "20151202",

  "tag_id": 2

}

使用 put   http://192.168.13.140:9200/baoyou/10120/17_1/

  "tag_id": 1

elastic search head 基本用法

2.删除資料

elastic search head 基本用法

3.查詢語句

{
  "size": 5,
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "tag_id": 2
          }
        },
        {
          "match": {
            "tag_id": 1
          }
        }
      ]
    }
  },
  "aggs": {
    "hello": {
      "terms": {
        "field": "token_id"
      }
    }
  }
}      
elastic search head 基本用法

4.更新資料

elastic search head 基本用法

更新資料 version 有所改變

 elastic search head 基本用法2

{
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "os": "iOS"
          }
        }
      ]
    }
  },
  "aggs": {
    "hello": {
      "terms": {
        "field": "device_resolution"
      }
    }
  }
}      
{
"took": 23,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 25187,
"max_score": 0,
"hits": [ ]
},
"aggregations": {
"hello": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "667*375",
"doc_count": 9379
}
,
{
"key": "568*320",
"doc_count": 8302
}
,
{
"key": "736*414",
"doc_count": 4475
}
,
{
"key": "480*320",
"doc_count": 3030
}
,
{
"key": "755*425",
"doc_count": 1
}
]
}
}
}      

 1. term  分詞

elastic search head 基本用法
elastic search head 基本用法
elastic search head 基本用法
elastic search head 基本用法

 term 分詞, long int 類型 , 17 的 分詞就是 17 , string 類型 為 空格 分割的單詞 。 test data 分詞之後是 test ,data . 【test data】 不是

    1. {"query":{"bool":{"must":[{"term":{"10120.tag_desc":"data"}}],"must_not":[],"should":[{"term":{"10120.tag_desc":"test"}}]}},"from":0,"size":10,"sort":[],"facets":{}}:
elastic search head 基本用法

2.range

  1. {"query":{"bool":{"must":[{"range":{"10120.token_id":{"from":"1","to":"18"}}}],"must_not":[],"should":[]}},"from":0,"size":10,"sort":[],"facets":{}}:
elastic search head 基本用法

 range 區間 範圍 隻對整形 有作用 ,string 無效。

3.fuzzy

    1. {"query":{"bool":{"must":[],"must_not":[],"should":[{"fuzzy":{"10120.token_id":{"value":"1","min_similarity":"20"}}}]}},"from":0,"size":10,"sort":[],"facets":{}}:
  1. elastic search head 基本用法
     fuzzy  區間    value +- min_similarity   本 執行個體中   是  -19 ~21 之間。

 4.query_string

elastic search head 基本用法
elastic search head 基本用法
elastic search head 基本用法
elastic search head 基本用法

query_string  可以對 int long string 進行 查詢。

   對 int long 隻能 本身查詢

   對 string 進行 分詞查詢  本身 也可以查詢。

 5. miss

   對 那列中 沒有 值的列 進行顯示。

 6. prefix

elastic search head 基本用法

 prefix 字首查詢

7. wildcard

    1. {"query":{"bool":{"must":[],"must_not":[],"should":[{"wildcard":{"10120.tag_desc":"t*"}}]}},"from":0,"size":10,"sort":[],"facets":{}}:
elastic search head 基本用法

 wildcard 通配符

捐助開發者

在興趣的驅動下,寫一個

免費

的東西,有欣喜,也還有汗水,希望你喜歡我的作品,同時也能支援一下。 當然,有錢捧個錢場(右上角的愛心标志,支援支付寶和PayPal捐助),沒錢捧個人場,謝謝各位。

elastic search head 基本用法
elastic search head 基本用法
elastic search head 基本用法

 謝謝您的贊助,我會做的更好!

繼續閱讀