白手起家之搜索利器ELastic search

這是我參與8月更文挑戰的第7天,活動詳情查看:8月更文挑戰css

基於開源的分佈式,全文搜索引擎:html

ELastic searchmysql

官網: www.elastic.co/cn/sql

image.png

下載:www.elastic.co/cn/download…數據庫

image.png

主要是用於數據的搜索,動態的查詢.數據的過濾等';瀏覽器

數據分爲:markdown

   結構化數據的,二維表的形式網絡

  非結構化的數據,圖標elasticsearch

  半結構化的數據 html,css.等語言信息分佈式

開始下載:

下載完成以後解壓縮:

image.png

image.png

image.png

http://localhost:9200     9200是一個客戶端的啓動端口

9300 端口爲 Elasticsearch 集羣間組件的通訊端口,9200 端口爲瀏覽器訪問的 http

議 協議 RESTful 端口。

image.png

表示啓動完成

image.png

將bin/elssticSearche.bat而後將數據請求一個地址  http://localhost:9200

image.png

es啓動成功 ,表示Elastic search成功啓動;

es 遵照RESTful原則的開發,   冪等性一致,可是post不是

資源的轉化,請求;

JSON格式

Javascript object  notation

var obj={ "name":"lucas"}`
複製代碼

JSON字符串:表示網絡中傳遞的字符串的格式符合JSON格式

倒排索引:

image.png

es基礎操做:

image.png

建立一個index(mysql中的數據庫database)

  

建立索引:(發生put請求)

 

http://localhost:9200/shopping     put請求表示建立,具體要冪等性,屢次建立同名的都會是同一個,es中對於
複製代碼

es對於索引,支持Get(獲取),put(建立),delete(刪除),

image.png

  image.png

image.png

查看當前索引的信息:

http://localhost:9200/shopping
複製代碼

image.png

複製代碼

查詢一下所有索引的信息:

image.png

http://localhost:9200/_cat/indices?v
複製代碼

刪除當前的索引:

http://localhost:9200/shopping
複製代碼

 image.png

建立文檔:

 

http://localhost:9200/shopping/_doc
複製代碼

image.png  

image.png

{
    "title": "小米手機",
    "category": "小米",
    "images": "http://www.gulixueyuan.com/xm.jpg",
    "price": 3999.00
}
 

複製代碼

image.png

{
"_index"【索引】: "shopping",
"_type"【 類型-文檔 】: "_doc",
"_id"【惟一標識】: "Xhsa2ncBlvF_7lxyCE9G", #能夠類比爲 MySQL 中的主鍵,隨機生成
"_version"【版本】: 1,
"result"【結果】: "created", #這裏的 create 表示建立成功
"_shards"【分片】: {
"total"【分片 - 總數】: 2,
"successful"【分片 - 成功】: 1,
"failed"【分片 - 失敗】: 0
},
"_seq_no": 0,
"_primary_term": 1
}

複製代碼

  上文有個惟一的標識; 也能夠自定義完成,基於

 

http://localhost:9200/shopping/_doc/1001    post
複製代碼
http://localhost:9200/shopping/create/1002   put
複製代碼

查看你文檔數據:

http://localhost:9200/shopping/_doc/1001   get
複製代碼

image.png

如何查詢當前索引下所有的文檔信息:  

http://localhost:9200/shopping/_search
複製代碼

image.png

put/ 是全量更新

post是局部更新;

image.png

刪除文檔:

image.png

image.png

相關文章
相關標籤/搜索