Запросы Cassandra Like Queries не работают с индексом SASI
Я пытаюсь сравнить вторичные индексы Cassandra Lucene. Стратио-люценовый индекс и SASIIndex.
Когда я пытаюсь запросить данные с использованием вторичного индекса, созданного с помощью SASI, запросы LIKE не возвращают все результаты.
Действия по воспроизведению.
CREATE TABLE movies_test (
id UUID,
title TEXT,
year INT,
runtime INT,
PRIMARY KEY ((id))
);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death in Vientiane', 2017, 16);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death at Preah Vihear', 2014, 51);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death of Manuel de Falla', 1991, 84);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death at the Ambassador Hotel', 1994, 51);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death in Flanders', 1963, 82);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death of the Hollywood Kid', 1994, 114);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death in Iraq', 2009, 58);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Debt', 2001, 80);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death of the Army of Northern Virginia', 2008, 50);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death on the A List', 1996, 50);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death', 1980, 83);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death', 1977, 91);
INSERT INTO movies_test (id, title, year, runtime) values (uuid(), 'Life and Death', 1936, 90);
CREATE CUSTOM INDEX title ON movies_test (title) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'mode': 'PREFIX'};
SELECT title, year, runtime FROM movies WHERE title like 'Life and De%';
title | year | runtime
-------------------------------------------------+------+---------
Life and Death in Vientiane | 2017 | 16
Life and Death at Preah Vihear | 2014 | 51
Life and Death of Manuel de Falla | 1991 | 84
Life and Death at the Ambassador Hotel | 1994 | 51
Life and Death in Flanders | 1963 | 82
Life and Death of the Hollywood Kid | 1994 | 114
Life and Death in Iraq | 2009 | 58
Life and Debt | 2001 | 80
Life and Death of the Army of Northern Virginia | 2008 | 50
Life and Death on the A List | 1996 | 50
Приведенный выше запрос не возвращает следующие 3 фильма.
title | year | runtime
----------------+------+---------
Life and Death | 1980 | 83
Life and Death | 1977 | 91
Life and Death | 1936 | 90
Если я попытаюсь выполнить аналогичный запрос с использованием индекса Stratio Lucene, я смогу запросить полные данные.
CREATE CUSTOM INDEX movies_test_index ON movies_test ()
USING 'com.stratio.cassandra.lucene.Index'
WITH OPTIONS = {
'refresh_seconds': '1',
'schema': '{
fields: {
title: {type: "string"}
}
}'
};
SELECT title, year, runtime FROM movies_test WHERE expr(movies_test_index, '{
query: {type: "prefix", field: "title", value: "Life and De"}
}');
title | year | runtime
-------------------------------------------------+------+---------
Life and Death at the Ambassador Hotel | 1994 | 51
Life and Death at Preah Vihear | 2014 | 51
Life and Death in Vientiane | 2017 | 16
Life and Death | 1980 | 83
Life and Death on the A List | 1996 | 50
Life and Death | 1936 | 90
Life and Death in Flanders | 1963 | 82
Life and Death of Manuel de Falla | 1991 | 84
Life and Death of the Hollywood Kid | 1994 | 114
Life and Death of the Army of Northern Virginia | 2008 | 50
Life and Death | 1977 | 91
Life and Death in Iraq | 2009 | 58
Life and Debt | 2001 | 80
Я не уверен, делаю ли я какие-либо ошибки при создании индекса SASI или во время запроса.
Пожалуйста помоги.
Было бы также хорошо, если бы кто-нибудь мог предложить, какие есть другие варианты сделать вторичный индекс в Apache Cassandra (не в версии Datastax).
В настоящее время я тестирую с использованием apache-cassandra-3.11.2.
Спасибо