A configuration file is passed explicitly with --config FILE to the index command. There is no implicit discovery: no file is looked up in the current directory, the home directory or the environment. The configuration is recorded in the index, so update reuses it.
The search command also accepts --config FILE, as a query-time override. That file may contain only synonyms, pathRules and metaRules; any other key is rejected with invalid_config. The override replaces the stored value of each key it names for that one search and changes nothing in the index. Library callers pass the same keys as options.config to search.
The file must be UTF-8 JSON of at most 1 MiB. The top level must be an object. Every key is optional; missing keys take the defaults shown. Unknown keys anywhere are rejected with invalid_config, as are wrong types, non-finite numbers, and the keys __proto__, constructor and prototype in the synonym map. Accessor properties are refused. Library callers get the same rules from validateConfig, and buildIndex applies them too. The configuration stored in an index file is validated again when the index is loaded.
fieldWeights (object). Weights for the BM25F fields. Keys title, path, body, meta. Defaults 3.0, 2.0, 1.0, 1.5. Each value is a number from 0 to 100; not all may be 0. The additive boosts for an exact title match, phrases, all terms in the title and all terms in the path are fixed constants; they do not scale with fieldWeights.
bm25 (object). k1 from 0 to 10 (default 1.2) and b from 0 to 1 (default 0.75).
pathRules (array, at most 1000). Items { "match": string, "boost": number }. The score of a result (BM25F plus boosts) is multiplied by boost when its root-relative path matches; boost must be greater than 0 and at most 100. Several matching rules multiply. match is a plain substring or a glob using * (any run of characters, including /) and ? (exactly one character). Both the pattern and the path are normalized (Unicode compatibility form, lower case), so rule matching ignores case. A pattern without a wildcard matches anywhere in the path; a pattern with a wildcard must match the whole path. No regular expressions are supported.
metaRules (array, at most 1000). Same shape and limits as pathRules, applied to the document's meta text (for example JSON keys). A pattern with a wildcard is matched anywhere inside the first 65536 characters of the meta text. The work spent on path and metadata rules during one search is bounded; when the budget is used up, the remaining candidates are scored without rules and the result reports truncated.
synonyms (object). Maps a term to 1 to 16 alternative terms (each at most 64 characters, no control characters), at most 1000 keys. A key must be a single word: a key made of several words never applies. An alternative may be several words; it matches a document that contains every one of its words. Alternatives match exact index terms only (no prefix or substring matching) and each counts as its own query term with the synonym factor. Synonyms are one-way: "car": ["automobile"] makes a query for car also match automobile, but not the reverse. For a symmetric group, list every term as a key with the other terms as its alternatives (see the example below). Synonyms are stored in the index. From the command line a change takes effect when you run index --config again, or immediately for one search with search --config; library callers can pass options.config to search.
include and exclude (arrays of at most 200 patterns). Matched against root-relative, forward-slash paths. Their pattern syntax is not the same as for pathRules and metaRules:
*matches any run of characters inside one path segment and?matches exactly one character inside one segment; neither crosses a/. (InpathRulesandmetaRules,*does match/.)- A segment that is exactly
**matches zero or more whole segments, sodocs/**/*.mdmatchesdocs/a.mdanddocs/x/y/a.md.**inside a longer segment (a**b) acts like a single*. - A pattern without a
/matches a name at any depth (su*matchessum.mdandsub/su1.md). A pattern containing a/is anchored at the root (docs/*.mddoes not matchother/docs/a.md). - A trailing
/means a directory:drafts/matches everything inside any folder calleddrafts, at any depth. A pattern without a trailing slash that happens to match a folder name (drafts,su*) matches only that entry; it does not exclude the files inside the folder. The trailing/is not directory-only: a file whose own name matches the pattern is matched as well, sosu*/excludes the filesum.mdand every folder whose name starts withsutogether with its contents, anddrafts/also excludes a file that is itself calleddrafts. - Matching is case-sensitive. (
pathRulesandmetaRulesignore case.)
Because * stops at a /, exclude ["private/*"] excludes only the files directly inside private; it does not exclude private/deep/x.md. To exclude everything below private at the root, use private/**; to exclude every folder called private at any depth, use private/. The same rules apply to include. Default: empty.
symlinks ("skip" or "within-root", default "skip"). With "skip" symbolic links are never followed. With "within-root" only links whose real target stays inside the root are followed. Every real directory is walked at most once, so a link to a directory that is already walked is skipped (its files are indexed under their real paths); links to files are followed.
csvRows (boolean, default false). When true each CSV row becomes a document with the path file.csv#rowN; the number of rows is capped.
jsonKeys (boolean, default true). When true JSON object keys are added to the meta field, so they are searchable. Set it to false to index values only.
limits (object). Lower the hard limits for a run. Keys and hard maximums: maxFiles 50000, maxFileBytes 2097152, maxTotalBytes 536870912, maxDepth 64, maxJsonDepth 64, maxJsonNodes 200000, maxCsvRows 10000, maxEntries 500000, maxTokensPerDoc 200000, maxTerms 1000000, maxTotalTokens 10000000, maxPostings 1000000, maxIndexBytes 134217728. Values are integers from 1 up to the maximum; a value above the maximum is rejected. Exceeding a limit while indexing fails with limit_exceeded. maxEntries counts directory entries visited in total, maxTotalTokens counts term occurrences over the whole corpus and maxPostings counts (term, document, field) entries. Documents are also capped at 50000 in total, counting every CSV row.
The syntax of include and exclude is described above; pathRules and metaRules use the syntax described in their own entries. Patterns in all four keys are rejected when they are empty, longer than 256 characters, contain control characters or a backslash, contain .. anywhere, start with /, ~ or a drive letter such as C:, or have leading or trailing whitespace.
{
"fieldWeights": { "title": 4.0, "body": 1.0 },
"bm25": { "k1": 1.2, "b": 0.75 },
"pathRules": [
{ "match": "archive/*", "boost": 0.5 },
{ "match": "handbook", "boost": 1.3 }
],
"synonyms": {
"car": ["automobile"],
"automobile": ["car"]
},
"exclude": ["drafts/"],
"symlinks": "skip",
"csvRows": true,
"limits": { "maxFiles": 10000, "maxFileBytes": 1048576 }
}