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

查看:29
本文介绍了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 企业 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天全站免登陆