quarkusio/quarkus · error · IllegalArgumentException

The schema cannot be empty, you configure the indexed fields

Error message

The schema cannot be empty, you configure the indexed fields

What it means

A RediSearch FT.CREATE index must declare at least one indexed field in its SCHEMA clause. CreateArgs.toArgs() throws IllegalArgumentException when the schema list built via field()/fieldAs... methods is empty, preventing sending a command Redis would reject.

Source

Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/search/CreateArgs.java:380

            list.add("NOFIELDS");
        }

        if (noFreqs) {
            list.add("NOFREQS");
        }

        if (stopWords != null && stopWords.length > 0) {
            list.add("STOPWORDS");
            list.add(Integer.toString(stopWords.length));
            Collections.addAll(list, stopWords);
        }

        if (skipInitialScan) {
            list.add("SKIPINITIALSCAN");
        }

        if (schema.isEmpty()) {
            throw new IllegalArgumentException("The schema cannot be empty, you configure the indexed fields");
        }
        list.add("SCHEMA");
        for (IndexedField field : schema) {
            list.addAll(field.toArgs());
        }

        return list;
    }

}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add at least one field to the CreateArgs schema, e.g. args.field("name").asText()
  2. Verify the source of dynamic schema fields is populated before calling create()
  3. Log or assert schema size before building the index

Example fix

// before
CreateArgs args = new CreateArgs().onHash();
ft.create("idx", args); // throws
// after
CreateArgs args = new CreateArgs().onHash();
args.field("title").asText().field("year").asNumeric();
ft.create("idx", args);
Defensive patterns

Strategy: validation

Validate before calling

if (schemaFields.isEmpty()) throw new IllegalStateException("FT.CREATE requires at least one indexed field in the schema");
CreateArgs args = new CreateArgs().onHash();
schemaFields.forEach(f -> args.field(f.getName()).asText());

Try / catch

try {
    ft.create(index, args);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("schema cannot be empty")) {
        throw new IllegalStateException("No indexed fields configured for index " + index, e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling ft().create(index, args) with an empty or never-populated schema — e.g. new CreateArgs().onHash() with no field() calls, or a schema whose field collection ended up empty due to failed filtering/empty config.

Common situations: Forgetting to add field(...)/fieldAsText(...) calls before create(); dynamic schema built from config or reflection that filtered out all fields; passing a schema collection that was empty at runtime.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/67cc6d78b2b2cc89. Report an issue: GitHub.