平臺搭建---大數據框架---分佈式搜索引擎與面向文檔數據庫(lucene、elasticsearch、Nutch、Solr)

文檔相似性

文本相似度計算-JaccardSimilarity和哈希簽名函數
https://blog.csdn.net/ygrx/article/details/12748857

lucene學習

來源:孔浩Lucene視頻教程
Lucene學習思維導圖
這裏寫圖片描述

分詞流程圖
這裏寫圖片描述

分詞器的類型
這裏寫圖片描述

分詞過濾器類型
這裏寫圖片描述

分詞結果輸出
這裏寫圖片描述

Lucene 4.0.0 core API

面向文檔的數據庫:(Elasticsearch的另一種用法)

Elasticsearch是一個基於lucene的分佈式搜索引擎,但是我們也可以將其作爲數據庫使用。可參考:查詢優化及查詢方案設計
Elasticsearch 使用的詳細教程:
Elasticsearch 權威指南(中文版)
官網
英文文檔

日均5億查詢量的京東訂單中心,爲什麼舍MySQL用ES

Elasticsearch 權威指南(中文版)

Elasticsearch的安裝

更詳細可參考
安裝前首先去ES的官網下載軟件包,下載地址爲:https://www.elastic.co/downloads/elasticsearch。官網提供ZIP、TAR 、MSI等多種格式的軟件包,在Windows下可以下載ZIP壓縮包或者MSI服務安裝包。
對於window系統,可下載ZIP壓縮文件包,例如下載的文件名爲“elasticsearch-6.3.0.zip”,可將其解壓到C盤根目錄(也可以是其他盤)。由目錄名可以清楚的瞭解每個目錄具體是做什麼的,比如:config目錄存放配置文件、logs目錄存放日誌文件、lib目錄存放依賴包、bin目錄存放系統啓動腳本等。進入bin目錄,雙擊“elasticsearch.bat”即可啓動Elasticsearch服務。出現“started”標誌就說明服務啓動成功。
在 Windows 上面運行 Elasticsearch,你可以從 http://curl.haxx.se/download.html 中下載 cURL。 cURL 給你提供了一種將請求提交到 Elasticsearch 的便捷方式,並且安裝 cURL 之後,你可以通過複製與粘貼去嘗試書中的許多例子。
安裝cURL 可參考《windows(64位)下使用curl安裝》、《windows環境下 curl 安裝和使用》,其中有windows控制檯curl中文亂碼的解決方法。

注意事項
運行elasticsearch6.3.0版本官網的例子時,應該如下運行

curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H "Content-Type: application/json" -d "{  \"name\": \"John Doe\"}"

參數都應該用雙引號,而直接複製官網例子,如Content-Type: application/json是單引號,此時會報"Content-Type header [application/x-www-form-urlencoded] is not supported";對於雙引號內部的雙引號,要加反斜槓;對於josn格式的數據,應該寫在同一行,不要用美化後的格式;

操作 命令 說明
索引文檔 PUT twitter/_doc/1
索引文檔 PUT twitter/_doc/1?version=2 都完整覆蓋
索引文檔 PUT twitter/_doc/1?op_type=create
索引文檔 PUT twitter/_doc/1/_create
索引文檔 POST twitter/_doc/
索引文檔 POST twitter/_doc?routing=kimchy
索引文檔 PUT twitter/_doc/1?timeout=5m
查詢文檔 curl -X GET "localhost:9200/twitter/_doc/0?pretty"
查詢文檔 curl -I HEAD "localhost:9200/twitter/_doc/0" HTTP/1.1 200 OK<br>content-type: application/json; <br>charset=UTF-8<br>content-length: 40
查詢文檔 GET twitter/_doc/0?_source=false 不顯示source的具體內容,只告知source有無內容
查詢文檔 GET twitter/_doc/0?_source_include=*.id&_source_exclude=entities 按照過濾條件顯示source的部分內容
查詢文檔 GET twitter/_doc/0?_source=*.id,retweeted 按照過濾條件顯示source的部分內容
設置索引格式 curl -X PUT "localhost:9200/twitter" -H "Content-Type: application/json" -d"{ \"mappings\": { \"_doc\": { \"properties\": { \"counter\": { \"type\": \"integer\", \"store\": false }, \"tags\": { \"type\": \"keyword\", \"store\": true } } } }}" 如果索引已經存在會出錯
查詢文檔 curl -X GET "localhost:9200/twitter/_doc/1?stored_fields=tags,counter" 如果不傳stored_fields會顯示完整的_source;傳的部分內容stored_fields則只顯示符合條件的fileds
索引文檔 curl -X PUT "localhost:9200/twitter/_doc/2?routing=user1" -H "Content-Type: application/json" -d"{ \"counter\" : 1, \"tags\" : [\"white\"]}" 增加_routing這個域,增加一個域可能會使得查詢的時候更好過濾
查詢文檔 curl -X GET "localhost:9200/twitter/_doc/2?routing=user1&stored_fields=tags,counter"
查詢文檔 curl -X GET "localhost:9200/twitter/_doc/1/_source" 直接獲取_source,而不顯示其他filed
查詢文檔 curl -X GET "localhost:9200/twitter/_doc/1/_source?_source_include=*.id&_source_exclude=entities" 加入過濾條件
刪除文檔 curl -X DELETE "localhost:9200/twitter/_doc/1"
刪除文檔 curl -X DELETE "localhost:9200/twitter/_doc/1?routing=kimchy"
刪除文檔 curl -X DELETE "localhost:9200/twitter/_doc/1?timeout=5m"
刪除type和index 操作方法類似
刪除文檔 curl -X POST "localhost:9200/twitter/_delete_by_query" -H "Content-Type: application/json" -d"{ \"query\": { \"match\": { \"message\": \"some message\" } }}" 按照查詢條件進行刪除
刪除文檔 curl -X POST "localhost:9200/twitter/_doc/_delete_by_query?conflicts=proceed" -H "Content-Type: application/json" -d"{ \"query\": { \"match_all\": {} }}"
刪除文檔 curl -X POST "localhost:9200/twitter,blog/_docs,post/_delete_by_query" -H "Content-Type: application/json" -d"{ \"query\": { \"match_all\": {} }}" 同時在多個索引中刪除文檔
刪除文檔 curl -X POST "localhost:9200/twitter/_delete_by_query?routing=1" -H "Content-Type: application/json" -d"{ \"query\": { \"range\" : { \"age\" : { \"gte\" : 10 } } }}"
刪除文檔 curl -X POST "localhost:9200/twitter/_delete_by_query?scroll_size=5000" -H "Content-Type: application/json" -d"{ \"query\": { \"term\": { \"user\": \"kimchy\" } }}"
任務查詢 curl -X GET "localhost:9200/_tasks?detailed=true&actions=*/delete/byquery" 按照任務命令查詢
任務查詢 curl -X GET "localhost:9200/_tasks/taskId:1" 按照任務id查詢
取消任務查詢 curl -X POST "localhost:9200/_tasks/task_id:1/_cancel"
取消任務查詢 curl -X POST "localhost:9200/_delete_by_query/task_id:1/_rethrottle?requests_per_second=-1"
按slice刪除 curl -X POST "localhost:9200/twitter/_delete_by_query" -H "Content-Type: application/json" -d"{ \"slice\": { \"id\": 0, \"max\": 2 }, \"query\": { \"range\": { \"likes\": { \"lt\": 10 } } }}"
更多用法可查官網

查詢億級數據毫秒級返回!牛逼哄哄的ElasticSearch是如何做到的?

實踐

滴滴基於 ElasticSearch 的一站式搜索中臺實踐
日均5億查詢量的京東訂單中心,爲什麼舍MySQL用ES?

Linux下Nutch分佈式配置和使用

Solar學習

solr簡介、學習詳細過程!(超詳細~)
Solar學習(一)—————>>>>>>>>>>>solr的最簡單的瞭解
Solr開發文檔
solr的基本使用

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章