Why GraphQL code search may return cached results and how to force fresh results
Problem
Occasionally GraphQL code search queries return cached or stale results, causing recently changed files to appear unchanged.
Why this happens
Sourcegraph periodically polls code hosts and may not immediately pick up recent commits.
Search results can be served from cache to reduce load and improve performance.
Repository indexing or commit graph updates may be delayed or in progress.
How to get fresh results
Wait briefly for the repository poll or indexer to pick up changes (depends on your Sourcegraph configuration).
Use repository-specific or commit-specific queries to target the exact ref or commit instead of a broad search. Example GraphQL variables:
{"query": "repo:my/repo@commit_or_branch file:^path/to/file.yml$"}If available, trigger a reindex or repo update in the Sourcegraph UI or via the code host integration API.
Confirm the code host has received and processed the push; ensure webhooks or syncs are functioning.
Troubleshooting tips
Compare results against the code host (e.g., Git) using the same commit SHA to confirm source of truth.
Check Sourcegraph logs or monitoring for indexing delays or errors.
Increase query specificity (exact file path, repo name, or commit) to avoid cached broader matches.
When to contact support
Contact support if reindexing doesn't surface the new changes, or if you see repeated indexing failures. Provide repository name, commit SHA, and approximate time of the push.