Wildcard search in cassandra database

送分小仙女□ 提交于 2020-01-11 08:24:22

问题


I want to know if there is any way to perform wildcard searches in cassandra database. e.g.

select KEY,username,password from User where username='\*hello*';

Or

select KEY,username,password from User where username='%hello%';

something like this.


回答1:


There is no native way to perform such queries in Cassandra. Typical options to achieve the same are

a) Maintain an index yourself on likely search terms. For example, whenever you are inserting an entry which has hello in the username, insert an entry in the index column family with hello as the key and the column value as the key of your data entry. While querying, query the index CF and then fetch data from your data CF. Of course, this is pretty restrictive in nature but can be useful for some basic needs.

b) A better bet is to use a full text search engine. Take a look at Solandra, https://github.com/tjake/Solandra or Datastax enterprise http://www.datastax.com/products/enterprise




回答2:


This project also looks promising http://tuplejump.github.io/stargate/

I have not looked deeply at it recently, but when I last evaluated it, it looked promising.



来源:https://stackoverflow.com/questions/11681522/wildcard-search-in-cassandra-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!