首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Cassandra更改表到Elasticsearch同步- Elassandra

从Cassandra更改表到Elasticsearch同步- Elassandra
EN

Stack Overflow用户
提问于 2016-10-12 11:29:35
回答 1查看 211关注 0票数 0

我通过elasticsearch创建了一个表,并与cassandra同步:

代码语言:javascript
复制
 _id | message                                    | postDate                            | user
-----+--------------------------------------------+-------------------------------------+------------
   2 |     ['Another tweet, will it be indexed?'] | ['2009-11-15 14:12:12.000000+0000'] | ['kimchy']
   1 | ['Trying out Elassandra, so far so good?'] | ['2009-11-15 13:12:00.000000+0000'] | ['kimchy']

当我修改表tweet并添加电子邮件栏时:

更改表推特添加电子邮件varchar;

代码语言:javascript
复制
```javascript

_id / email / message \ postDate \\ user

-----+-------+--------------------------------------------+-------------------------------------+

另一条推文,它会被索引吗?“x”2009-11-15 14:12:12.000000+0000‘AC.26 'kimchy’

尝试Elassandra,到目前为止还好吗?‘复合物'2009-11-15 13:12:00.000000+0000’\x 'kimchy‘

代码语言:javascript
复制
``` The email has been added but and appears **null**.

但是当我查询elasticsearch时,它不同步:

代码语言:javascript
复制
{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "twitter",
      "_type" : "tweet",
      "_id" : "2",
      "_score" : 1.0,
      "_source":{"postDate":"2009-11-15T14:12:12.000Z","message":"Another tweet, will it be indexed?","user":"kimchy"}
    }, {
      "_index" : "twitter",
      "_type" : "tweet",
      "_id" : "1",
      "_score" : 1.0,
      "_source":{"postDate":"2009-11-15T13:12:00.000Z","message":"Trying out Elassandra, so far so good?","user":"kimchy"}
    } ]
  }
}

问题是如何将表的更改从cassandra同步到elasticsearch?

EN

回答 1

Stack Overflow用户

发布于 2017-09-27 08:35:00

这是一个旧的职位,但我回答,以防有人发现它。

在Elassandra中,当您创建cassandra表或列时,它不会被弹性搜索自动索引。您需要创建或更新映射:

代码语言:javascript
复制
curl -XPUT "http://localhost:9200/twitter/" -d '{
   "settings" : { "keyspace" : "twitter" } },
   "mappings" : {
      "tweet" : {
            "properties" : {
              "email" : { "type" : "string", "index" : "not_analyzed" },
            }
      }
   }
}

现在,elasticsearch索引包含一个新的email字段。任何新的电子邮件插入CQL将自动索引,并可在一秒内进行搜索。

但重要的是要注意,在地图更新之前添加的电子邮件条目还不能搜索。有必要使用nodetool来重建索引,其中包括:

代码语言:javascript
复制
nodetool flush tweeter
nodetool rebuild_index --threads 4 tweeter tweet elastic_tweet_idx
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39997474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档