开发者

is there any trick to do wildcards search on apache cassandra?

开发者 https://www.devze.com 2023-01-04 21:42 出处:网络
i need to do something like this on apache cassandra, SELECT * FROM mytable where address = \"%indonesia%\"

i need to do something like this on apache cassandra, SELECT * FROM mytable where address = "%indonesia%"

any idea how to 开发者_开发百科do it on cassandra?


Its not supported out of the box. You must maintain your own indices.

I would recommend to use "Supercolumn index" or use a order preserving partitioner (e.g. org.apache.cassandra.dht.OrderPreservingPartioner) in conjunction with range queries.

Take a look at the slides from Benjamin Black's excellent talk about cassandra and index


Just to add to what Schildmeijer has said, unless you do a lot of extra work, you're probably not going to get the equivalent of an "%indonesia%" wildcard search in Cassandra. Much easier will be "indonesia%" or "%indonesia" (or "aisenodni%") using a range query on a special index that you've created for searches like this. The slides that Schildmeijer links to describe how to set up this kind of search at a high level.

If you're looking for full text search in blocks of text that are being stored in Cassandra, you might look into something like Lucene to maintain an index that can be used for doing certain kinds of searches over strings in the text. I am not too familiar with the details, but following are two links that might be helpful here:

  • http://github.com/tjake/Lucandra
  • http://lucene.apache.org/java/docs/index.html
0

精彩评论

暂无评论...
验证码 换一张
取 消