Skip to content

Commit 11d6bd6

Browse files
docs: update how to add doc index backend
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
1 parent a74af43 commit 11d6bd6

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

docs/how_to/add_doc_index.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ To define what can be stored in them, and what the default values are, you need
288288
```python
289289
@dataclass
290290
class DBConfig(BaseDocIndex.DBConfig):
291-
...
291+
default_column_config: Dict[Type, Dict[str, Any]] = ...
292292

293293

294294
@dataclass
295295
class RuntimeConfig(BaseDocIndex.RuntimeConfig):
296-
default_column_config: Dict[Type, Dict[str, Any]] = ...
296+
...
297297
```
298298

299299
!!! note
@@ -306,16 +306,8 @@ The `DBConfig` class defines the static configurations of your Document Index.
306306
These are configurations that are tied to the database (or library) running in the background, such as `host`, `port`, etc.
307307
Here you should put everything that the user cannot or should not change after initialization.
308308

309-
### The `RuntimeConfig` class
310-
311-
The `RuntimeConfig` class defines the dynamic configurations of your Document Index.
312-
These are configurations that can be changed at runtime, for example default behaviours such as batch sizes, consistency levels, etc.
313-
314-
It is a common pattern to allow such parameters both in the `RuntimeConfig`, where they will act as global defaults, and
315-
in specific methods (`index`, `find`, etc.), where they will act as local overrides.
316-
317309
!!! note
318-
Every `RuntimeConfig` needs to contain a `default_column_config` field.
310+
Every `DBConfig` needs to contain a `default_column_config` field.
319311
This is a dictionary that, for each possible column type in your database, defines a default configuration for that column type.
320312
This will automatically be passed to a `_ColumnInfo` whenever a user does not manually specify a configuration for that column.
321313

@@ -327,6 +319,15 @@ and for `varchar` columns you could define a `max_length` configuration.
327319

328320
It is probably best to see this in action, so you should check out the `HnswDocumentIndex` implementation.
329321

322+
### The `RuntimeConfig` class
323+
324+
The `RuntimeConfig` class defines the dynamic configurations of your Document Index.
325+
These are configurations that can be changed at runtime, for example default behaviours such as batch sizes, consistency levels, etc.
326+
327+
It is a common pattern to allow such parameters both in the `RuntimeConfig`, where they will act as global defaults, and
328+
in specific methods (`index`, `find`, etc.), where they will act as local overrides.
329+
330+
330331
## Implement abstract methods for indexing, searching, and deleting
331332

332333
After you've done the basic setup above, you can jump into the good stuff: implementing the actual indexing, searching, and deleting.
@@ -374,7 +375,7 @@ class MySchema(BaseDoc):
374375

375376
In this case, the `db_type` of `my_num` will be `'float64'` and the `db_type` of `my_text` will be `'varchar'`.
376377
Additional information regarding the `col_type`, such as `max_len` for `varchar` will be stored in the `_ColumnsInfo.config`.
377-
The given `col_type` has to be a valid `db_type`, meaning that has to be described in the index's `RuntimeConfig.default_column_config`.
378+
The given `col_type` has to be a valid `db_type`, meaning that has to be described in the index's `DBConfig.default_column_config`.
378379

379380
### The `_index()` method
380381

0 commit comments

Comments
 (0)