在cassandra数据库中进行通配符搜索 [英] Wildcard search in cassandra database

查看:204
本文介绍了在cassandra数据库中进行通配符搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何方法在cassandra数据库中执行通配符搜索。
例如

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*';

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

这样。

推荐答案

在Cassandra中没有本地方法来执行这样的查询。实现相同操作的典型选项是

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

a)在可能的搜索字词上自行维护索引。例如,每当您插入在用户名中有hello的条目时,在索引列族中插入一个条目,hello作为键,列值作为数据条目的键。在查询时,查询索引CF,然后从数据CF中提取数据。当然,这在本质上是相当限制性的,但可以用于一些基本需要。

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)更好的办法是使用全文搜索引擎。查看Solandra, https://github.com/tjake/Solandra 或Datastax enterprise http://www.datastax.com/products/enterprise

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

这篇关于在cassandra数据库中进行通配符搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆