apache/seatunnel · error · TypesenseConnectorException

CREATE_COLLECTION_ERROR

CREATE_COLLECTION_ERROR

Error message

CREATE_COLLECTION_ERROR.getDescription()

What it means

TypesenseClient.createCollection() calls the Typesense create-collection API; a failure is rethrown as TypesenseConnectorException with CREATE_COLLECTION_ERROR. This happens when the collection already exists or the API rejects the schema.

Solutions

  1. Check collectionExists(collection) before creating, or catch the 409 and treat it as success/idempotent
  2. Validate the generated field list (each field needs a valid name and Typesense-supported type)
  3. Ensure the API key has admin/collection-write permissions
  4. Attach the cause to the rethrown exception to see Typesense's specific error message

Example fix

// before
public boolean createCollection(String collection) {
    ... build schema ...
    tsClient.collections().create(collectionSchema);
    return true;
}
// after
public synchronized boolean createCollection(String collection) {
    if (collectionExists(collection)) {
        return true;
    }
    ... build schema ...
    tsClient.collections().create(collectionSchema);
    return true;
}
Defensive patterns

Strategy: validation

Validate before calling

if (client.collectionExists(collection)) {
    return; // already created — skip create to avoid conflict error
}

Try / catch

try {
    client.createCollection(collection);
} catch (TypesenseConnectorException e) {
    // check if cause is 409 already-exists and treat as success, otherwise rethrow
}

Prevention

When it happens

Trigger: Calling createCollection(collection) when a collection with that name already exists (Typesense returns 409), the field schema is invalid (bad field types, missing 'name' field type), or the API key lacks collection-creation rights.

Common situations: Re-running a job/schema-sync without drop-first so the collection already exists; schema fields mapping to invalid Typesense types; read-only API keys in config.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/6b4983f6fc614e2e. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/client/TypesenseClient.java:237

    public boolean createCollection(String collection) {
        if (collectionExists(collection)) {
            return true;
        }
        List<Field> fields = new ArrayList<>();
        fields.add(new Field().name(".*").type(FieldTypes.AUTO));
        return createCollection(collection, fields);
    }

    public boolean createCollection(String collection, List<Field> fields) {
        CollectionSchema collectionSchema = new CollectionSchema();
        collectionSchema.name(collection).fields(fields).enableNestedFields(true);
        try {
            tsClient.collections().create(collectionSchema);
            return true;
        } catch (Exception e) {
            log.error(CREATE_COLLECTION_ERROR.getDescription());
            throw new TypesenseConnectorException(
                    CREATE_COLLECTION_ERROR, CREATE_COLLECTION_ERROR.getDescription());
        }
    }

    public boolean dropCollection(String collection) {
        try {
            tsClient.collections(collection).delete();
            return true;
        } catch (Exception e) {
            log.error(DROP_COLLECTION_ERROR.getDescription());
            throw new TypesenseConnectorException(
                    DROP_COLLECTION_ERROR, DROP_COLLECTION_ERROR.getDescription());
        }
    }

    public boolean truncateCollectionData(String collection) {
        DeleteDocumentsParameters deleteDocumentsParameters = new DeleteDocumentsParameters();
        deleteDocumentsParameters.filterBy("id:!=1||id:=1");

View on GitHub (pinned to cf67b549a7)