我通过elasticsearch创建了一个表,并与cassandra同步:
_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_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‘
``` The email has been added but and appears **null**.但是当我查询elasticsearch时,它不同步:
{
"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?
发布于 2017-09-27 08:35:00
这是一个旧的职位,但我回答,以防有人发现它。
在Elassandra中,当您创建cassandra表或列时,它不会被弹性搜索自动索引。您需要创建或更新映射:
curl -XPUT "http://localhost:9200/twitter/" -d '{
"settings" : { "keyspace" : "twitter" } },
"mappings" : {
"tweet" : {
"properties" : {
"email" : { "type" : "string", "index" : "not_analyzed" },
}
}
}
}现在,elasticsearch索引包含一个新的email字段。任何新的电子邮件插入CQL将自动索引,并可在一秒内进行搜索。
但重要的是要注意,在地图更新之前添加的电子邮件条目还不能搜索。有必要使用nodetool来重建索引,其中包括:
nodetool flush tweeter
nodetool rebuild_index --threads 4 tweeter tweet elastic_tweet_idxhttps://stackoverflow.com/questions/39997474
复制相似问题