嗯,这就是我想要的,但它不起作用。我创建了这个 create table test (id int, string text, primary key (id));。然后我在 string 上创建了一个索引,之后我执行了这个查询:select * from test where string like 'and';,但是我没有得到任何答案。我已经尝试在 like 子句中使用 %,但问题仍然存在。 - Alexandre S.
这是我的索引:create custom index test on test(string) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = { 'mode': 'CONTAINS', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer', 'analyzed': 'true', 'tokenization_skip_stop_words': 'and, the, or', 'tokenization_enable_stemming': 'true', 'tokenization_normalize_lowercase': 'true', 'tokenization_locale': 'en' };。我的查询是:select * from test where string like 'and'。 - Alexandre S.
我正在使用Cassandra 3.6版本。 - Alexandre S.
仍然返回0行,我错过了什么吗?我的表包含这两行:
insert into test (id, string) values (1, 'test');insert into test (id, string) values (2, 'banana and black'); - Alexandre S.
create table test (id int, string text, primary key (id));
。然后我在 string 上创建了一个索引,之后我执行了这个查询:select * from test where string like 'and';
,但是我没有得到任何答案。我已经尝试在 like 子句中使用 %,但问题仍然存在。 - Alexandre S.create custom index test on test(string) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = { 'mode': 'CONTAINS', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer', 'analyzed': 'true', 'tokenization_skip_stop_words': 'and, the, or', 'tokenization_enable_stemming': 'true', 'tokenization_normalize_lowercase': 'true', 'tokenization_locale': 'en' };
。我的查询是:select * from test where string like 'and'
。 - Alexandre S.insert into test (id, string) values (1, 'test');
insert into test (id, string) values (2, 'banana and black');
- Alexandre S.StandardAnalyzer
跳过and
。请注意验证您是否能够通过其他单词获取(例如插入一个包含单词cassandra
的句子并查找%sand%
)。 - xmas79