Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/java/org/apache/cassandra/db/filter/RowFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1164,9 +1164,9 @@ public final Index.Analyzer queryAnalyzer()
@Override
public int numFilteredValues()
{
return indexAnalyzer == null
return queryAnalyzer == null
? super.numFilteredValues()
: indexAnalyzer().analyze(value).size();
: queryAnalyzer().analyze(value).size();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,29 @@ public void testQueryFilters() throws Throwable
assertWarns("SELECT * FROM %s WHERE x = '1 2 3' AND y = '4 5 6' AND z = '7 8 9' ALLOW FILTERING", 3);
}

@Test
public void testQueryFiltersWithIndexAndQueryAnalyzers() throws Throwable
{
createTable("CREATE TABLE %s (k int PRIMARY KEY, v text)");

createIndex("CREATE CUSTOM INDEX ON %s(v) USING 'StorageAttachedIndex' WITH OPTIONS = {" +
"'index_analyzer': '{\n" +
"\t\"tokenizer\":{\"name\":\"ngram\", \"args\":{\"minGramSize\":\"1\", \"maxGramSize\":\"10\"}}," +
"\t\"filters\":[{\"name\":\"lowercase\"}]\n" +
"}'," +
"'query_analyzer': '{\n" +
"\t\"tokenizer\":{\"name\":\"whitespace\"},\n" +
"\t\"filters\":[{\"name\":\"porterstem\"}]\n" +
"}'};");

// only the query analyzer should be used to calculate the number of filters
assertValid("SELECT * FROM %s WHERE v = 'abcdef'");
assertValid("SELECT * FROM %s WHERE v = 'abcdef ghijkl'");
assertWarns("SELECT * FROM %s WHERE v = 'abcdef ghijkl mnopqr'", 3);
assertWarns("SELECT * FROM %s WHERE v = 'abcdef ghijkl mnopqr stuvwx'", 4);
assertFails("SELECT * FROM %s WHERE v = 'abcdef ghijkl mnopqr stuvwx xyz'", 5);
}

@Test
public void testExcludedUsers() throws Throwable
{
Expand Down