Skip to content

Commit f83a4db

Browse files
committed
add maxTrigramCount setting
1 parent d1ef80d commit f83a4db

File tree

6 files changed

+18
-2
lines changed

6 files changed

+18
-2
lines changed

packages/backend/src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Settings } from "./types.js";
55
*/
66
export const DEFAULT_SETTINGS: Settings = {
77
maxFileSize: 2 * 1024 * 1024, // 2MB in bytes
8+
maxTrigramCount: 20000,
89
autoDeleteStaleRepos: true,
910
reindexInterval: 1000 * 60 * 60, // 1 hour in milliseconds
1011
resyncInterval: 1000 * 60 * 60 * 24, // 1 day in milliseconds

packages/backend/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ const syncConfig = async (configPath: string, db: Database, signal: AbortSignal,
209209
// Update the settings
210210
const updatedSettings: Settings = {
211211
maxFileSize: config.settings?.maxFileSize ?? DEFAULT_SETTINGS.maxFileSize,
212+
maxTrigramCount: config.settings?.maxTrigramCount ?? DEFAULT_SETTINGS.maxTrigramCount,
212213
autoDeleteStaleRepos: config.settings?.autoDeleteStaleRepos ?? DEFAULT_SETTINGS.autoDeleteStaleRepos,
213214
reindexInterval: config.settings?.reindexInterval ?? DEFAULT_SETTINGS.reindexInterval,
214215
resyncInterval: config.settings?.resyncInterval ?? DEFAULT_SETTINGS.resyncInterval,

packages/backend/src/schemas/v2.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export interface Settings {
2121
* The maximum size of a file (in bytes) to be indexed. Files that exceed this maximum will not be inexed. Defaults to 2MB (2097152 bytes).
2222
*/
2323
maxFileSize?: number;
24+
/**
25+
* The maximum amount of trigrams per document. Documents that exceed this maximum will not be indexed. Defaults to 20000
26+
*/
27+
maxTrigramCount?: number;
2428
/**
2529
* Automatically delete stale repositories from the index. Defaults to true.
2630
*/

packages/backend/src/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ export type AppContext = {
4646

4747
export type Settings = {
4848
/**
49-
* The maximum size of a file (in bytes) to be indexed. Files that exceed this maximum will not be inexed.
49+
* The maximum size of a file (in bytes) to be indexed. Files that exceed this maximum will not be indexed.
5050
*/
5151
maxFileSize: number;
52+
/**
53+
* The maximum number of trigrams per document. Files that exceed this maximum will not be indexed.
54+
*/
55+
maxTrigramCount: number;
5256
/**
5357
* Automatically delete stale repositories from the index. Defaults to true.
5458
*/

packages/backend/src/zoekt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const indexGitRepository = async (repo: GitRepository, settings: Settings
1010
...repo.tags ?? [],
1111
];
1212

13-
const command = `zoekt-git-index -allow_missing_branches -index ${ctx.indexPath} -file_limit ${settings.maxFileSize} -branches ${revisions.join(',')} ${repo.path}`;
13+
const command = `zoekt-git-index -allow_missing_branches -index ${ctx.indexPath} -max_trigram_count ${settings.maxTrigramCount} -file_limit ${settings.maxFileSize} -branches ${revisions.join(',')} ${repo.path}`;
1414

1515
return new Promise<{ stdout: string, stderr: string }>((resolve, reject) => {
1616
exec(command, (error, stdout, stderr) => {

schemas/v2/index.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,12 @@
570570
"default": 2097152,
571571
"minimum": 1
572572
},
573+
"maxTrigramCount": {
574+
"type": "integer",
575+
"description": "The maximum amount of trigrams per document. Documents that exceed this maximum will not be indexed. Defaults to 20000",
576+
"default": 20000,
577+
"minimum": 1
578+
},
573579
"autoDeleteStaleRepos": {
574580
"type": "boolean",
575581
"description": "Automatically delete stale repositories from the index. Defaults to true.",

0 commit comments

Comments
 (0)