ElasticSearch 总结

ElasticSearch 总结

[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读取数据的插件

  • 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 中同步业务数据

  • 配置文件: 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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容