Skip to content

Commit d60af4c

Browse files
Copilotabnegate
andauthored
docs(readme): use builder style for skip index and SETTINGS examples
Agent-Logs-Url: https://github.com/utopia-php/query/sessions/b1fda15b-7a7c-4a63-a597-31ee644b3c39 Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
1 parent df22caf commit d60af4c

1 file changed

Lines changed: 16 additions & 20 deletions

File tree

README.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,42 +2091,38 @@ TTL expressions are emitted verbatim; they must not be empty or contain semicolo
20912091
```php
20922092
use Utopia\Query\Schema\ClickHouse\IndexAlgorithm;
20932093

2094-
$schema->create('events', function (Table $table) {
2095-
$table->bigInteger('id')->primary();
2096-
$table->string('user_id');
2097-
$table->string('country');
2098-
$table->string('text');
2099-
2094+
$schema->table('events')
2095+
->bigInteger('id')->primary()
2096+
->string('user_id')
2097+
->string('country')
2098+
->string('text')
21002099
// BloomFilter — high-cardinality strings with `=` / `IN` predicates
2101-
$table->index(['user_id'], algorithm: IndexAlgorithm::BloomFilter);
2102-
2100+
->index(['user_id'], algorithm: IndexAlgorithm::BloomFilter)
21032101
// Set(N) — small fixed value sets, custom granularity
2104-
$table->index(['country'], algorithm: IndexAlgorithm::Set, algorithmArgs: [100], granularity: 4);
2105-
2102+
->index(['country'], algorithm: IndexAlgorithm::Set, algorithmArgs: [100], granularity: 4)
21062103
// NgramBloomFilter(n, size_bytes, hashes, seed) — text search on `LIKE` / `match`
2107-
$table->index(['text'], algorithm: IndexAlgorithm::NgramBloomFilter, algorithmArgs: [4, 1024, 3, 0]);
2108-
2104+
->index(['text'], algorithm: IndexAlgorithm::NgramBloomFilter, algorithmArgs: [4, 1024, 3, 0])
21092105
// No algorithm specified → defaults to `TYPE minmax GRANULARITY 3`
2110-
$table->index(['id']);
2111-
});
2106+
->index(['id'])
2107+
->create();
21122108

21132109
// CREATE TABLE `events` (..., INDEX `idx_user_id` `user_id` TYPE bloom_filter GRANULARITY 1, ...)
21142110
```
21152111

21162112
The 6 algorithms are `MinMax`, `Set`, `BloomFilter`, `NgramBloomFilter`, `TokenBloomFilter`, `Inverted`. Algorithm-specific arguments are passed via `algorithmArgs` and rendered verbatim — supply them from trusted (developer-controlled) source. Other dialects ignore the ClickHouse-only `algorithm` / `algorithmArgs` / `granularity` arguments.
21172113

2118-
`MinMax` and `Inverted` take no parenthesised arguments in ClickHouse DDL — passing `algorithmArgs` for them throws `ValidationException`. Skip indexes can also be added via `ALTER TABLE … ADD INDEX` by calling `index()` inside an `alter()` callback.
2114+
`MinMax` and `Inverted` take no parenthesised arguments in ClickHouse DDL — passing `algorithmArgs` for them throws `ValidationException`. Skip indexes can also be added via `ALTER TABLE … ADD INDEX` by calling `alter()` on the builder.
21192115

21202116
**Engine SETTINGS** — emit `SETTINGS k=v` after the TTL clause:
21212117

21222118
```php
2123-
$schema->create('events', function (Table $table) {
2124-
$table->bigInteger('id')->primary();
2125-
$table->settings([
2119+
$schema->table('events')
2120+
->bigInteger('id')->primary()
2121+
->settings([
21262122
'index_granularity' => 8192,
21272123
'allow_nullable_key' => true, // booleans become 1/0
2128-
]);
2129-
});
2124+
])
2125+
->create();
21302126

21312127
// CREATE TABLE `events` (...) ENGINE = MergeTree() ORDER BY (`id`)
21322128
// SETTINGS index_granularity = 8192, allow_nullable_key = 1

0 commit comments

Comments
 (0)