apache/cassandra · error · InvalidRequestException

is only supported on properly indexed columns or with ALLOW…

Error message

%s is only supported on properly indexed columns or with ALLOW FILTERING

What it means

When a LIKE restriction is added to the RowFilter, Cassandra looks for a suitable index for the LIKE expression; if none exists and ALLOW FILTERING was not specified, the query is rejected. LIKE must be backed by a compatible index (e.g. SASI/SAI) or the user must opt into unindexed filtering.

Solutions

  1. Create a supporting index (e.g. SAI LIKE-capable index) on the column
  2. Append ALLOW FILTERING to the query (full scan; use cautiously on large tables)
  3. Replace LIKE with an indexed equality/prefix strategy (e.g. dedicated search column)

Example fix

// before
SELECT * FROM users WHERE name LIKE '%son%';
// after
CREATE INDEX IF NOT EXISTS users_name_idx ON users (name) USING 'sai' WITH OPTIONS = {'case_sensitive': false};
SELECT * FROM users WHERE name LIKE '%son%';
Defensive patterns

Strategy: validation

Validate before calling

// check schema before issuing LIKE
IndexMetadata idx = schema.getIndex(column);
if (idx == null || !idx.supportsLike()) requireAllowFilteringOrReject();

Try / catch

catch (InvalidRequestException e) { if (e.getMessage().contains("only supported on properly indexed")) createIndexOrAddAllowFiltering(); }

Prevention

When it happens

Trigger: SELECT ... WHERE text_col LIKE '%foo%' without a LIKE-capable index on text_col and without ALLOW FILTERING.

Common situations: Full-text-style search added after the fact with no SAI/SASI index created; schema migrations where the index was dropped; assumptions that LIKE works like SQL on any text column.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/ce9ef818e2ee1847. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/restrictions/SimpleRestriction.java:397

        ColumnMetadata column = firstColumn();
        switch (columnsExpression.kind())
        {
            case SINGLE_COLUMN:
                List<ByteBuffer> buffers = bindAndGet(context);
                if (operator.kind() != Operator.Kind.BINARY)
                {
                    if (operator == Operator.IN && !column.type.isCounter())
                        buffers.sort(column.type);
                    filter.add(column, operator, multiInputOperatorValues(column, buffers));
                }
                else if (operator == Operator.LIKE)
                {
                    LikePattern pattern = LikePattern.parse(buffers.get(0));
                    
                    RowFilter.SimpleExpression expression = filter.add(column, pattern.kind().operator(), pattern.value());
                    Optional<Index> index = indexRegistry.getBestIndexFor(expression, indexHints);
                    if(!index.isPresent() && !allowFiltering)
                        throw invalidRequest("%s is only supported on properly indexed columns or with ALLOW FILTERING", expression);
                }
                else
                {
                    filter.add(column, operator, buffers.get(0));
                }
                break;
            case MULTI_COLUMN:
                checkFalse(isSlice(), "Multi-column slice restrictions cannot be used for filtering.");

                if (isEQ())
                {
                    List<ByteBuffer> elements = bindAndGetElements(context).get(0);

                    for (int i = 0, m = columns().size(); i < m; i++)
                    {
                        ColumnMetadata columnDef = columns().get(i);
                        filter.add(columnDef, Operator.EQ, elements.get(i));
                    }

View on GitHub (pinned to 88fd0f6a0e)