ElasticSearch 總結(jié)
[TOC]
ElasticSearch console:
http://192.168.1.155:9200/_plugin/head
ElasticSearch plugins
soudang@192.168.1.155:/data/elasticsearch-1.4.2/plugins
analysis-ik 分詞插件
head 管理Console
jdbc 從DB讀取數(shù)據(jù)的插件
- Project: SearchBridge
- SearchBridge/src/main/java/com/soudang/mobile/search/bridge/PawnHistory/PawnHistoryContinue.java
DB 與 ElasticSearch 的 mapping 定義
soudang@192.168.1.155:/data/elasticsearch-1.4.2/plugins/jdbc/foreverrun.sh
SoudangPawnsFileFeeder.java 配置文件
每間隔3秒從pawndb_head.changeLog, pawndb_head db 中同步業(yè)務(wù)數(shù)據(jù)
配置文件: ddt.config
/data/elasticsearch-1.4.2/plugins/jdbc/sync_corps155.sh
調(diào)用jdbc插件從mobile_db中同步企業(yè)信息數(shù)據(jù)
/data/elasticsearch-1.4.2/plugins/jdbc/sync_corps155_db.sh
curl -O http://192.168.1.155:8090/llt/rest/admin/syncCorporation
/data/elasticsearch-1.4.2/plugins/jdbc/watcher.sh
watcher dog 的實現(xiàn)例子
#!/bin/sh
script_found=` ps -ef |grep -v grep | grep SoudangPawnsFileFeeder | awk '{print $12}'`
if [ -z "$script_found" ]
then
echo "the script is not running `date`" >> /tmp/watcher.log
cd /data/elasticsearch-1.4.2/plugins/jdbc
nohup ./sync_pawns155File.sh &
echo "start the script ..." >> /tmp/watcher.log
else
echo "the script is running $script_found `date`" >> /tmp/watcher.log
fi
從elasticSearch 中查詢:
- Project: llt
- 查詢API 例子: llt/src/com/soudang/mobile/rest/resources/StatsResource.java
基礎(chǔ)知識
Elasticsearch 與 數(shù)據(jù)庫的對應(yīng)
Relational DB -> Databases -> Tables -> Rows -> Columns
Elasticsearch -> Indices -> Types -> Documents -> Fields
索引
- 名詞:相關(guān)文檔存儲的地方,類似關(guān)系型數(shù)據(jù)庫中的數(shù)據(jù)庫
- 動詞: 把一個文檔存儲到索引里谷市,以便能檢索或查詢到带射,類似insert
- 倒排索引: 類似數(shù)據(jù)庫中為某個列加索引, 在ElasticSearch中是倒排索引
查詢的例子
http://192.168.1.155:9200/soudang/pawnhistory/_search?q=corporationid:626
Index: soudang
type: pawnhistory
_search 查詢
q=<> 查詢參數(shù)
a->b:aaa