Skip to content

Commit 3563704

Browse files
author
福晋
committed
chore: remove dynamic fts fields
1 parent f846ecf commit 3563704

5 files changed

Lines changed: 21 additions & 16 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ await ctx.close();
6161
| `basePath` | `string` | `process.cwd()` | Base path for resolving document IDs. Set for cross-machine consistent IDs. |
6262
| `onProgress` | `(phase, detail) => void` | — | Progress callback for `load()` phases: `'load'` → `'embed'` → `'insert'`. |
6363
| `queryExpansion` | `QueryExpansionOptions` | `false` | Query expansion with user-provided synonym map. false disables. Without synonyms, expansion is a no-op. |
64-
| `ftsFields` | `string[]` | `['content']` | Fields to index for Full Text Search in hybrid mode |
65-
| `ftsFieldWeights` | `Record<string, number>` | `{ content: 1 }` | Per-field boost weights for FTS text path. Higher = more influence. |
64+
| `ftsFields` | `string[]` | `['indexContent']` | Fields queried by Full Text Search in hybrid mode |
65+
| `ftsFieldWeights` | `Record<string, number>` | `{ indexContent: 1 }` | Per-field boost weights for FTS text path. Higher = more influence. |
6666
| `rankConstant` | `number` | `60` | RRF rank constant for hybrid search fusion. Lower = "winner-takes-all", higher = more even. |
6767
6868
#### Weight Configuration Example
@@ -140,9 +140,9 @@ await ctx.load('g2', './docs/**/*.md', {
140140
});
141141
```
142142
143-
When `buildIndexContent` is provided, its result is used for embedding and can
144-
be queried by configuring `ftsFields: ['indexContent']`. The original
145-
`document.content` is stored unchanged and returned by `query()`.
143+
When `buildIndexContent` is provided, its result is used for embedding and the
144+
default `indexContent` FTS query. The original `document.content` is stored
145+
unchanged and returned by `query()`.
146146
147147
Load phases emit progress via the `onProgress` callback:
148148

‎src/storage/schema.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@ const INDEX_TYPES = {
2222
export function buildZvecSchema(
2323
dims: number,
2424
tokenizerName: string = 'jieba',
25-
ftsFields: string[] = ['content'],
25+
ftsFields: string[] = ['indexContent'],
2626
): ZVecCollectionSchema {
2727
const fts = (name: string): Pick<ZvecFieldSchema, 'indexType' | 'indexOptions'> =>
2828
ftsFields.includes(name)
2929
? { indexType: 'FTS', indexOptions: { tokenizerName } }
3030
: {};
3131
const fields: ZvecFieldSchema[] = [
3232
{ name: 'content', dataType: 'STRING', ...fts('content') },
33-
{ name: 'indexContent', dataType: 'STRING', ...fts('indexContent') },
33+
{
34+
name: 'indexContent',
35+
dataType: 'STRING',
36+
indexType: 'FTS',
37+
indexOptions: { tokenizerName },
38+
},
3439
{ name: 'meta', dataType: 'STRING' },
3540
{ name: 'path', dataType: 'STRING' },
3641
{ name: 'contentHash', dataType: 'STRING' },

‎src/storage/store.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Embedder } from '../embedder';
88
import type { ContextOptions } from '../types';
99

1010
const VECTOR_FIELD = 'embedding';
11-
const FTS_FIELDS = ['content'];
11+
const FTS_FIELDS = ['indexContent'];
1212

1313
/**
1414
* Store - zvec storage for multiple libraries.

‎src/types.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ export interface ContextOptions {
119119
/**
120120
* Fields to index for Full Text Search (FTS).
121121
*
122-
* By default, `content` is indexed. Add more fields (e.g. `meta.title`)
123-
* to include metadata in text-based recall.
122+
* By default, hybrid search queries `indexContent`, which falls back to
123+
* the original `content` when no buildIndexContent callback is provided.
124124
*
125125
* Only affects newly created stores — existing stores keep their schema.
126126
*/
@@ -133,7 +133,7 @@ export interface ContextOptions {
133133
* Example: `{ content: 1, title: 3 }` makes title matches 3× more
134134
* influential than content matches.
135135
*
136-
* Defaults to `{ content: 1 }` when `ftsFields` includes `content`.
136+
* Defaults to `{ indexContent: 1 }`.
137137
*/
138138
ftsFieldWeights?: Record<string, number>;
139139

‎test/storage/schema.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ describe('buildZvecSchema', () => {
1717
expect(schemaStr).toContain('metric:COSINE');
1818
});
1919

20-
it('should include content field with FTS index and jieba tokenizer (default)', () => {
20+
it('should include indexContent with FTS and jieba tokenizer by default', () => {
2121
const schema = buildZvecSchema(128, 'jieba');
2222
const schemaStr = String(schema);
2323

24-
expect(schemaStr).toContain("name: 'content'");
24+
expect(schemaStr).toContain("name: 'indexContent'");
2525
expect(schemaStr).toContain('FtsIndexParams');
2626
expect(schemaStr).toContain('tokenizer_name:jieba');
2727
});
2828

29-
it('should include indexContent with an FTS index', () => {
30-
const schema = buildZvecSchema(128, 'jieba', ['indexContent']);
29+
it('should allow content to be additionally indexed', () => {
30+
const schema = buildZvecSchema(128, 'jieba', ['content']);
3131
const schemaStr = String(schema);
3232

33-
expect(schemaStr).toContain("name: 'indexContent'");
33+
expect(schemaStr).toContain("name: 'content'");
3434
expect(schemaStr).toContain('FtsIndexParams');
3535
});
3636

0 commit comments

Comments
 (0)