Skip to main content

Indexes for fast code search

Our plugin has two types of search: similar search and exact search.

Both indexes are built on classic information retrieval methods, so they are very fast and can be computed even on low-powered machines. These indexes do not rely on any ML resources, in particular they do not use embeddings, vector databases, or anything similar.

Exact search looks for an arbitrary substring in the project source code. Its index is an inverted n-gram index that source texts and queries are mapped to. On large projects, this search is faster than the built-in IntelliJ Platform search.

Use exact search when you already know the exact text: an identifier name, a fragment of an error message, a string literal, or part of a configuration. For example, you can find every place where the code builds the message Connection refused.

To run a search:

  1. Give the agent the exact fragment and the search scope: a file, a directory, or the whole project.
  2. If case matters, explicitly ask the agent to respect it.

Example request:

Find the exact string Connection refused in the whole project, case-sensitive.

Similar search in project code

Similar search is a lightweight alternative to semantic search with embeddings. It searches by meaning using BM25 and an analyzer that supports keywords, natural-language morphology, camel case, synonyms, and language-specific optimizations.

Use similar search when you know what the code does but not the exact class, method, or file name. For example, searching by meaning helps you find the code that refreshes an expired access token even if the implementation uses the names renewCredentials and refreshSession.

Describe to the agent what the code you need does. The agent prepares the search query itself and adds suitable keywords.

Example request:

Find the code that refreshes an expired access token.

Similar search in dependencies

The similar search index includes available library sources. Use search in dependencies when you need to find the right API in the exact library version connected to the project and you don't know the exact type or method name. For example, you can find the handler in an HTTP client that retries a request after an authorization error.

Name the library or the task its API should solve, and ask the agent to search dependency sources. The agent prepares the keywords for the tool call itself. After the search, it can open the source it found and check the signature.

Example request:

Find an HTTP client API in the dependency sources for retrying a request after an authorization error, and check the signature.