Elasticsearch下应用Siren Federate插件

插件下载

https://siren.io/downloads/?product=siren-federate
下载到的文件名是:siren-federate-6.8.2-10.3.1.zip,(版本差异可能文件名不同)。

解压缩

下载zip文件后,解压缩到某个文件夹,比如我这里就解压缩到了:
D:\software\ELK-v6.8.2\siren-federate-6.8.2-10.3.1
​​在这里插入图片描述

安装

在Windows命令提示符下面,进入Elasticsearch所在的目录:

C:\ELK\elasticsearch-6.8.2\bin>elasticsearch-plugin install file:///D:/software/ELK-v6.8.2/siren-federate-6.8.2-10.3.1/siren-federate-6.8.2-10.3.1-proguard-plugin.zip

创建并上传两个indices

首先要安装一个Cygwin客户端,在Cygwin的控制台里面以此执行下面5条命令:

$ curl -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/articles'
$ curl -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/articles/_mapping/article' -d '
{
  "properties": {
    "mentions": {
      "type": "keyword"
    }
  }
}
'
$ curl -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/companies'
$ curl -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/companies/_mapping/company' -d '
{
  "properties": {
    "id": {
      "type": "keyword"
    }
  }
}
'

$ curl -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/_bulk?pretty' -d '
{ "index" : { "_index" : "articles", "_type" : "article", "_id" : "1" } }
{ "title" : "The NoSQL database glut", "mentions" : ["1", "2"] }
{ "index" : { "_index" : "articles", "_type" : "article", "_id" : "2" } }
{ "title" : "Graph Databases Seen Connecting the Dots", "mentions" : [] }
{ "index" : { "_index" : "articles", "_type" : "article", "_id" : "3" } }
{ "title" : "How to determine which NoSQL DBMS best fits your needs", "mentions" : ["2", "4"] }
{ "index" : { "_index" : "articles", "_type" : "article", "_id" : "4" } }
{ "title" : "MapR ships Apache Drill", "mentions" : ["4"] }

{ "index" : { "_index" : "companies", "_type" : "company", "_id" : "1" } }
{ "id": "1", "name" : "Elastic" }
{ "index" : { "_index" : "companies", "_type" : "company", "_id" : "2" } }
{ "id": "2", "name" : "Orient Technologies" }
{ "index" : { "_index" : "companies", "_type" : "company", "_id" : "3" } }
{ "id": "3", "name" : "Cloudera" }
{ "index" : { "_index" : "companies", "_type" : "company", "_id" : "4" } }
{ "id": "4", "name" : "MapR" }
'

这样就生成了两个indice,如果以表格的形式展示,就是这样的:
Companies

idname
1Elastic
2Orient Technologies
3Cloudera
4MapR

articles

mentionstitle
Graph Databases Seen Connecting the Dots
4MapR ships Apache Drill
1, 2The NoSQL database glut
2, 4How to determine which NoSQL DBMS best fits your needs

Join查询

$ curl -H 'Content-Type: application/json' 'http://localhost:9200/siren/articles/_search?pretty' -d '{
   "query" : {
      "join" : {                      
        "indices" : ["companies"],    
        "on" : ["mentions", "id"],    
        "request" : {                 
          "query" : {
            "term" : {
              "name" : "orient"
            }
          }
        }
      }
    }
}'

Join在DevTools中查询

GET /siren/companies/_search
{
  "query" : {
    "join" : {                      
        "indices" : ["companies"],    
        "on" : ["mentions", "id"],    
        "request" : {                 
          "query" : {
            "term" : {
              "name" : "orient"
            }
          }
        }
      }
  }
}

得到的结果:

{
  "took" : 198,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : 0.0,
    "hits" : [
      {
        "_index" : "articles",
        "_type" : "article",
        "_id" : "1",
        "_score" : 0.0,
        "_source" : {
          "title" : "The NoSQL database glut",
          "mentions" : [
            "1",
            "2"
          ]
        }
      },
      {
        "_index" : "articles",
        "_type" : "article",
        "_id" : "3",
        "_score" : 0.0,
        "_source" : {
          "title" : "How to determine which NoSQL DBMS best fits your needs",
          "mentions" : [
            "2",
            "4"
          ]
        }
      }
    ]
  },
  "planner" : {
    "node" : "OWQQ6GlWTU-4zKyp_pCPaQ",
    "took_in_millis" : 2214,
    "timestamp" : {
      "start_in_millis" : 1569742126495,
      "stop_in_millis" : 1569742128709,
      "took_in_millis" : 2214
    },
    "is_pruned" : false
  }
}

生成安全码:

D:\DSUsers\uidt8491\ELK\elasticsearch-6.8.2\plugins\siren-federate\tools>java -cp ..\* io.siren.federate.tools.KeyGen -s 128
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值