You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 27, 2020. It is now read-only.
After digging into the lucene docs, I found following are the characters I should escape if present in my query string:
+ - && || ! ( ) { } [ ] ^ " ~ * ? : \ /
But if the query contains a single quote which is not present in the above list of characters also throws error. So my question is how do I escape my query in this plugin and what are the characters that needs to be escaped? Also I'm assuming the escape character is \ (backslash) and not " (quote) like in cassandra.
The text was updated successfully, but these errors were encountered:
The aforementioned special characters are part of the Lucene query syntax and should be escaped with double backslash (\). This escaping is only used in queries depending on Lucene syntax. Also, single quotation mark (') is a special character for CQL, and it should be escaped with another single quotation mark in all CQL occurrences.
Here you have a small example showing both types of escaping:
CREATE KEYSPACE test WITH replication = {'class':'SimpleStrategy', 'replication_factor': 1};
USE test;
CREATE TABLE test (
id int PRIMARY KEY,
text text);
INSERT INTO test(id, text) VALUES (2, 'a''b'); -- Ecaped quotation mark
INSERT INTO test(id, text) VALUES (3, 'a[b]');
-- Note the stored single quotation
SELECT * FROM test;
-- Create index
CREATE CUSTOM INDEX test_idx ON test() using 'com.stratio.cassandra.lucene.Index'
WITH OPTIONS = {
'refresh_seconds' : '1',
'schema' : '{ fields : { text : {type : "string"} } }'
};
SELECT * FROM test WHERE expr(test_idx, '{filter : {type: "match", field : "text", value : "a''b"}}'); -- Escaped quotation mark
SELECT * FROM test WHERE expr(test_idx, '{filter : {type: "match", field : "text", value : "a[b]"}}'); -- Escaping is not required
SELECT * FROM test WHERE expr(test_idx, '{filter : {type: "wildcard", field : "text", value : "a\\[b\\]"}}'); -- Escaped brackets
SELECT * FROM test WHERE expr(test_idx, '{filter : {type: "lucene", query : "text:a\\[b\\]"}}'); -- Escaped brackets
After digging into the lucene docs, I found following are the characters I should escape if present in my query string:
But if the query contains a single quote which is not present in the above list of characters also throws error. So my question is how do I escape my query in this plugin and what are the characters that needs to be escaped? Also I'm assuming the escape character is \ (backslash) and not " (quote) like in cassandra.
The text was updated successfully, but these errors were encountered: