elasticsearch基本操作

2021-10-24 12:27:32 字數 2846 閱讀 9073

1. 建立索引。

建立book索引

put  192.168.0.132:9200/book

i3 .修改索引資料

192.168.0.131:9200/book/novel/6/_update

}192.168.0.131:9200/索引/型別/id/_update

4.刪除索引資料

5. 查詢

根據id查詢索引

get 192.168.0.131:9200 /索引/型別/id

查詢所有資料

查詢資料分頁

get          192.168.0.131:9200/book/_search

},"from":0,

"size": 10

}match 查詢

get          192.168.0.131:9200/book/_search}}

排序get          192.168.0.131:9200/book/_search

},"sort":[} ]

}聚合查詢

get   192.168.0.131:9200/book/_search}}

get   192.168.0.131:9200/book/_search}}

短語匹配(phrase matching)

get  192.168.0.131:9200/book/_search}}

multi_match 查詢

get  192.168.0.131:9200/book/_search}}

query_string  查詢

get  192.168.0.131:9200/book/_search}}

get  192.168.0.131:9200/book/_search}}

term 查詢

get  192.168.0.131:9200/book/_search}}

range 查詢

get  192.168.0.131:9200/book/_search}}

}query filter 查詢

get  192.168.0.131:9200/book/_search}}

}}固定分數查詢

get  192.168.0.131:9200/book/_search}}

}}bool查詢

should

get  192.168.0.131:9200/book/_search},}

]}}}

must

get  192.168.0.131:9200/book/_search},}

]}}}

must_not

get  192.168.0.131:9200/book/_search}}

}}巢狀查詢

"settings":{

"number_of_shards":3,

"number_of_replicas": 1

"earthblog": {

"properties": {

"orderid": {

"type": "keyword"

"totalamount": {

"type": "long"

"discountamount":{

"type": "long"

"status":{

"type": "integer"

"createtime":{

"type": "date",

"format": "yyyy-mm-dd hh:mm:ss || yyyy-mm-dd||epoch_millis"

"orderdetails": {

"type": "nested",

"properties": {

"productid": {

"type": "long"

"productname": {

"analyzer": "ik_max_word",

"type": "text"

"producttype": {

"type": "short"

"status": {

"type": "short"

"createtime":{

"type": "date",

"format": "yyyy-mm-dd hh:mm:ss || yyyy-mm-dd||epoch_millis"

巢狀查詢

192.168.0.132:9200/order/order/_search

"query": {

"bool": {

"must": [

"nested": {

"path": "orderdetails",

"query": {

"bool": {

"must": [{

"match": {

"orderdetails.productname": "aoc顯示器"

"match": {

"orderdetails.producttype": 1

Elasticsearch 基本操作

mget elasticsearch中檢索多個文件,相對於乙個乙個的檢索,更快的方式是在乙個請求中使用multi get或者 mget api。具體應用如下 mget api引數是乙個 docs 陣列,陣列的每個節點定義乙個文件的 index type id 元資料。如果你只想檢索乙個或幾 個確定的...

elasticsearch基本操作

get search 建立索引 指定分片和副本 put lib 建立索引 put lib2 檢視索引的配置 get lib settings get lib2 settings get all settings 新增文件put方式指定id put lib user 1 新增文件,不指定id用post...

Elasticsearch 基本操作

乙個批量匯入elasticsearch 的demo 機器少的話,分片數最好是你的data節點的機器數倍數,這樣請求負載能夠均攤到每個機器上,如果機器比較多,最好保證分片數不要太多,比如最好別超過20 30個,然後根據你的資料量評估一下,盡量保證每個分片在15到20g吧 資料 vi request.j...