Code Search vs Semantic Code Search
People think a search by meaning replaces a search by text, and it does not. Text search finds the exact word or pattern you type, in every file. Semantic search turns code and your question into numbers and finds the closest match, even with no word in common. Use text search when you know the name. Use semantic search when you only know what the code does.
Code Search
Finding code by its text or a pattern. It can look in one project or many.
Code search finds code by what it says, across one project or many. The simplest kind looks for an exact word or a pattern in every file. Better tools know the language, so they can search only function names or skip comments. Big companies run it across thousands of projects at once. It is often the first step before any change.
Semantic Code Search
Finding code by what it means. A plain question finds the right function.
Semantic code search finds code by what it does, not by the words in it. Each piece of code is turned into a list of numbers called an embedding. Code that does similar things gets similar numbers. Your question is turned into numbers too, and the closest code comes back. AI coding tools use it to find the right files to read.
In one line
- Code Search
- Finding code by its text or a pattern. It can look in one project or many.
- Semantic Code Search
- Finding code by what it means. A plain question finds the right function.