Why files are skipped from indexing
Why files are skipped from indexing
Overview
Sourcegraph indexes code on the default branch of each repository to speed up searches across many repositories. Not every file is eligible for indexed search. This article explains why files may be skipped, how administrators can identify the reason, and what to do next.
Common reasons files are skipped
File size: By default, files larger than 1 MB are excluded.
Binary content: Binary files are not indexed.
Trigram limit: Files with more than 20,000 unique trigrams—sequences of three characters—are skipped.
Invalid encoding: Files that are not valid UTF-8 are skipped.
How to see why a file was skipped
Admin access is required.
Open the repository in Sourcegraph.
Go to Repository settings → Indexing.
Click the N skipped files link.
In the generated search query, remove
select:fileto display content results.Look for the
NOT-INDEXEDreason, such asNOT-INDEXED: exceeds the maximum size limitor an encoding-related message. The exact wording may vary by reason and Sourcegraph version.
What to do next
Large text files: Add the file path or a glob pattern to the
search.largeFilessetting in site configuration, then reindex the repository. This setting can force eligible text files, such asyarn.lock, to be included regardless of size.Binary files: Binary files remain excluded even when they match
search.largeFiles.Invalid UTF-8: Convert the file to valid UTF-8. Files must still be valid UTF-8 even when they match
search.largeFiles.
Further reading
See Indexed search in the Sourcegraph documentation.