is there any trick to do wildcards search on apach

2019-06-22 12:38发布

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

any idea how to do it on cassandra?

2条回答
Viruses.
2楼-- · 2019-06-22 13:25

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

查看更多
Luminary・发光体
3楼-- · 2019-06-22 13:40

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:

查看更多
登录 后发表回答