ElasticSearch 使用groovy指令碼

2021-10-03 15:15:46 字數 1487 閱讀 7133

1 put accounts/person/12

2 get accounts/person/12

返回:}

3 自增操作

post /accounts/person/12/_update

返回:}

4 檢視

get accounts/person/12

返回:}

age完成了自增

1 增加指令碼檔案路徑:elasticsearch-5.2.0/config/scripts/add_tags.groovy

內容:

ctx._source.tags+=new_tag

2 傳送命令

1 put accounts/person/13

2 get accounts/person/13

}3 post /accounts/person/13/_update

}}返回:}

4 get accounts/person/13

}

1 增加指令碼檔案路徑:elasticsearch-5.2.0/config/scripts/delete.groovy

內容:如果num為輸入的引數,者刪除

ctx.op=ctx._source.age==age?'delete':'none'

2 傳送命令

1 get accounts/person/13

返回:}

2 post /accounts/person/13/_update

}}返回:result為noop,者刪除失敗

}3 post /accounts/person/13/_update

}}返回:result為deleted,刪除成功

}4 get accounts/person/13

返回

1 直接進行partial update操作

post /accounts/person/15/_update

}返回錯誤:

],"type": "document_missing_exception",

"reason": "[person][15]: document missing",

"index_uuid": "qgpjjuv6sm-vbesoomlnpa",

"shard": "2",

"index": "accounts"

},"status": 404

}2 增加upsert引數

post /accounts/person/15/_update

, "upsert":

}返回:

}3 get accounts/person/15

返回:}

誰在使用Elasticsearch

github github使用elasticsearch搜尋20tb的資料,包括13億的檔案和1300億行的 這個不用介紹了吧,碼農們都懂的,github在2013年1月公升級了他們的 搜尋,由solr轉為elasticsearch,目前集群規模為26個索引儲存節點和8個客戶端節點 負責處理搜尋請求...

ElasticSearch使用入門

es的安裝 啟動 cd.elasticsearch 2 4 3 bin elasticsearch bin elasticsearch d 後台執行 es安裝驗證 注意 預設啟動的時候es繫結的網路ip是本機127.0.0.1,只能通過這個ip訪問 兩種修改方式 1 修改config elastic...

ElasticSearch使用學習

elasticsearch是乙個基於lucene的搜尋服務,它通過倒排索引的方法提供了全文搜尋的能力。1 插入資料 elasticsearch中存放資料的為文件,有索引及型別名,如下插入兩文件 2 檢索文件 1 檢索id為1的文件 curl x get elasticsearch.in.netwa....