<!-- generated by build_articles.py — edit content/answers/semantic-code-search.md instead -->
---
title: "What is semantic code search?"
canonical: "https://xerj.org/answers/semantic-code-search"
updated: "2026-11-14"
source: "content/answers/semantic-code-search.md"
---

# What is semantic code search?

**Short answer** (updated 2026-11-14): What is semantic code search? It ranks source passages by meaning, not only by the exact words in the query. On XERJ you can also look up definitions with syntax-aware search, which uses tree-sitter across 36 languages, or fuse both rankings with hybrid search. The default embedding mode is lexical, not neural.

**Key number:** XERJ covers 36 languages via tree-sitter, pinned by a unit test. A file over 2 MiB is skipped, at most 5,000 symbols per file, and names over 200 bytes are dropped. There is no call graph. (as of 2026-11-13; source: [landing/science/syntax-aware-search.html](https://github.com/xerj-org/xerj/blob/main/landing/science/syntax-aware-search.html))

**TL;DR** Semantic code search ranks source by meaning, not only by exact words. Use it when you can describe the behaviour but do not know the symbol name. XERJ also offers syntax-aware definitions through tree-sitter in 36 languages, and hybrid search that fuses a full-text ranking with a semantic or vector ranking. The default embedding mode is lexical, not neural.

## Agent prompt

```text
Act as a coding agent. Read https://xerj.org/llms.txt, start a node with `xerj --insecure --data-dir ./.xerj-data`, index the repository with `xerj autoindex . --url http://127.0.0.1:9200 --progress plain`, then use `xerj def` when you know the symbol name and `xerj search` when you only have a description. Cite file:line. If the node was not started with --embed-mode neural, say that the default embedding mode is lexical.
```

## Commands

### Command 1

Note: Install the release binary into ~/.local/bin.

```sh
curl -fsSL https://xerj.org/get | sh
```

### Command 2

Note: Start a local development node. Default embedding mode is lexical, not neural.

```sh
xerj --insecure --data-dir ./.xerj-data
```

### Command 3

Note: Index the repository, including definitions tree-sitter can parse.

```sh
xerj autoindex . --url http://127.0.0.1:9200 --progress plain
```

### Command 4

Note: Go to a definition by name, with file:line and a signature.

```sh
xerj def "BuiltinPager"
```

### Command 5

Note: Ranked passages when you can describe the behaviour but not the symbol.

```sh
xerj search "how is pagination implemented"
```

*Figure: Language count and caps are the published syntax-aware figures. On a XERJ node the default embedding mode is lexical, not neural. Start the node with --embed-mode neural when you want the built-in neural embedder.*

## Meaning, not only words

Semantic code search ranks passages that share meaning with the query. A question like "how is pagination implemented" can surface a function whose name you did not type. Exact-string search cannot do that job well, unless the identifier is already in the query. On a XERJ node the default embedding mode is lexical, not neural. Start the node with `--embed-mode neural` when you want the built-in neural embedder.

The concept, outside of code, is [What is semantic search?](/science/semantic-search). How it sits next to vector search and hybrid search is [Hybrid search, vector search, or semantic search?](/science/hybrid-vs-vector-vs-semantic-search).

On a XERJ node the default embedding mode is lexical, not neural. Semantic queries still run in that mode, as word and sub-word overlap plus BM25. Start the node with `--embed-mode neural` when you want the built-in neural embedder.

## Syntax-aware lookup, when you know the name

When you already know the symbol, go to the definition. XERJ does this with [syntax-aware search](/science/syntax-aware-search), through tree-sitter, in 36 languages. A file over 2 MiB is skipped, at most 5,000 symbols per file, and names over 200 bytes are dropped. There is no call graph. `xerj def` is the CLI for that path.

## Hybrid, when the query is mixed

Many real queries mix a name and a description. [Hybrid search](/science/hybrid-search) fuses a full-text ranking such as BM25 with a semantic or vector ranking, often with reciprocal rank fusion. That is usually the better default when you are not sure which words the source uses. On a XERJ node the default embedding mode is lexical, not neural.

## Tools and GitHub checkouts

An agent can call the same index through the MCP server. A comparison of local code search MCP tools, checked 2026-10-19, is [Best code search MCP tools, tested](/compare/best-mcp-server-local-code-search-2026).

To search a GitHub checkout, clone it and run `xerj autoindex`. For selected public corpora, `xerj ask` answers from a signed pack without a clone. That path is limited to the Corpus Hub catalogue, and it is a different product surface than semantic search over an arbitrary repo. On a XERJ node the default embedding mode is lexical, not neural.

A local search engine for agents, not only for code, is [What is a local AI search engine?](/answers/local-ai-search-engine).

## Read next

[Syntax-aware search](/science/syntax-aware-search), [semantic search](/science/semantic-search), [hybrid search](/science/hybrid-search) and [grep and ripgrep alternatives](/compare/best-grep-alternative-for-ai-coding-agents-2026).

## FAQ

### What is semantic code search?

It ranks source passages by meaning, not only by the exact words in the query. Use it when you can describe the behaviour but do not know the symbol name.

### How is that different from syntax-aware search?

Syntax-aware search finds definitions and other syntactic forms, using a parser such as tree-sitter. It is the right tool when you already know the name. Semantic search is the right tool when you only have a description.

### Does XERJ do semantic code search by default?

The default embedding mode is lexical, not neural. Semantic queries still run, but they use word and sub-word overlap plus BM25 unless you start the node with --embed-mode neural.

### Can I search a GitHub repo this way?

Clone the repo, or index a local checkout, then run xerj autoindex. For selected public corpora, xerj ask answers from a signed pack without a clone. That is a different path, limited to the Corpus Hub catalogue.

### How do I call this from an agent?

Use xerj mcp. On main it registers 24 tools, or 21 with no Corpus Hub key. The comparison of local code search MCP tools is on Best code search MCP tools, tested.

## Evidence

- XERJ covers 36 languages via tree-sitter, pinned by a unit test. A file over 2 MiB is skipped, at most 5,000 symbols per file, and names over 200 bytes are dropped. There is no call graph. — `landing/science/syntax-aware-search.html`
- On main, xerj mcp registers 24 MCP tools, or 21 when the binary has no Corpus Hub key. — `landing/docs/agents/schemas/mcp-tools.json`

## Related

- [What is semantic search?](/science/semantic-search)
- [What is syntax-aware search?](/science/syntax-aware-search)
- [What is hybrid search?](/science/hybrid-search)
- [Hybrid vs vector vs semantic search](/science/hybrid-vs-vector-vs-semantic-search)
- [Best MCP servers for code search in 2026: 7 compared](/compare/best-mcp-server-local-code-search-2026)
- [What is a local AI search engine?](/answers/local-ai-search-engine)
- [Is ripgrep enough for a coding agent, or do I need a code index?](/compare/xerj-vs-ripgrep-for-code-agents) (same intent: code search for agents)
- [How do I audit a PHP codebase with an index instead of grepping 1,400 files?](/answers/audit-php-codebase-with-an-index) (same intent: code search for agents)
- [My codebase indexer says indexed but I don't see my code. How do I check it actually finished?](/answers/check-codebase-index-is-complete) (same intent: code search for agents)
