ElasticSearch 总结

ElasticSearch 总结

[TOC]

ElasticSearch console:

http://192.168.1.155:9200/_plugin/head

ElasticSearch plugins

[email protected]:/data/elasticsearch-1.4.2/plugins

analysis-ik 分词插件

head 管理Console

jdbc 从DB读取数据的插件

  • Project: SearchBridge
  • SearchBridge/src/main/java/com/soudang/mobile/search/bridge/PawnHistory/PawnHistoryContinue.java

DB 与 ElasticSearch 的 mapping 定义

[email protected]:/data/elasticsearch-1.4.2/plugins/jdbc/foreverrun.sh

  • SoudangPawnsFileFeeder.java 配置文件

  • 每间隔3秒从pawndb_head.changeLog, pawndb_head db 中同步业务数据

  • 配置文件: ddt.config

/data/elasticsearch-1.4.2/plugins/jdbc/sync_corps155.sh

调用jdbc插件从mobile_db中同步企业信息数据

/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 的实现例子

#!/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

基础知识

Elasticsearch 与 数据库的对应

Relational DB -> Databases -> Tables -> Rows -> Columns
Elasticsearch -> Indices   -> Types  -> Documents -> Fields

索引

  • 名词:相关文档存储的地方,类似关系型数据库中的数据库
  • 动词: 把一个文档存储到索引里,以便能检索或查询到,类似insert
  • 倒排索引: 类似数据库中为某个列加索引, 在ElasticSearch中是倒排索引

查询的例子

http://192.168.1.155:9200/soudang/pawnhistory/_search?q=corporationid:626

Index: soudang
type: pawnhistory
_search 查询
q=<> 查询参数

a->b:aaa

你可能感兴趣的:(ElasticSearch 总结)