Cassandra Lucene 索引布尔语法
Cassandra Lucene Index boolean syntax
我正在我的 Cassandra 数据库中执行用户搜索系统。为此,我从 Stratio 安装了 Cassandra Lucene Index。
我可以通过用户名查找用户,但问题如下:
这是我的 Cassandra 用户 table 和 Lucene 索引:
CREATE TABLE user (
username text PRIMARY KEY,
email text,
password text,
is_verified boolean,
lucene text
);
CREATE CUSTOM INDEX search_main ON user (lucene) USING 'com.stratio.cassandra.lucene.Index' WITH OPTIONS = {
'refresh_seconds': '3600',
'schema': '{
fields : {
username : {type : "string"},
is_verified : {type : "boolean"}
}
}'
};
这是通过用户名查找用户的正常查询:
SELECT * FROM user WHERE lucene = '{filter: {type : "wildcard", field : "username", value : "*%s*"}}' LIMIT 15;
我的问题是:
如何对返回的结果进行排序以确保所有经过验证的用户都在查询的前 15 个结果之间? (限制为 15)。
您可以使用此搜索:
SELECT * FROM user WHERE lucene = '{filter: {type:"boolean", must:[
{type : "wildcard", field : "username", value : "*%s*"},
{type : "match", field : "is_verified", value : true}
]}}' LIMIT 15;
我正在我的 Cassandra 数据库中执行用户搜索系统。为此,我从 Stratio 安装了 Cassandra Lucene Index。 我可以通过用户名查找用户,但问题如下:
这是我的 Cassandra 用户 table 和 Lucene 索引:
CREATE TABLE user (
username text PRIMARY KEY,
email text,
password text,
is_verified boolean,
lucene text
);
CREATE CUSTOM INDEX search_main ON user (lucene) USING 'com.stratio.cassandra.lucene.Index' WITH OPTIONS = {
'refresh_seconds': '3600',
'schema': '{
fields : {
username : {type : "string"},
is_verified : {type : "boolean"}
}
}'
};
这是通过用户名查找用户的正常查询:
SELECT * FROM user WHERE lucene = '{filter: {type : "wildcard", field : "username", value : "*%s*"}}' LIMIT 15;
我的问题是:
如何对返回的结果进行排序以确保所有经过验证的用户都在查询的前 15 个结果之间? (限制为 15)。
您可以使用此搜索:
SELECT * FROM user WHERE lucene = '{filter: {type:"boolean", must:[
{type : "wildcard", field : "username", value : "*%s*"},
{type : "match", field : "is_verified", value : true}
]}}' LIMIT 15;