[Paper Review] Code Search: A Survey of Techniques for Finding Code
This survey provides a comprehensive, 30-year review of code search research, analyzing query types, preprocessing, indexing, retrieval, ranking, and pruning techniques. It identifies key challenges and opportunities, including natural language queries, cross-language search, and the need for better benchmarks and evaluation methods to support future research in code retrieval systems.
The immense amounts of source code provide ample challenges and opportunities during software development. To handle the size of code bases, developers commonly search for code, e.g., when trying to find where a particular feature is implemented or when looking for code examples to reuse. To support developers in finding relevant code, various code search engines have been proposed. This article surveys 30 years of research on code search, giving a comprehensive overview of challenges and techniques that address them. We discuss the kinds of queries that code search engines support, how to preprocess and expand queries, different techniques for indexing and retrieving code, and ways to rank and prune search results. Moreover, we describe empirical studies of code search in practice. Based on the discussion of prior work, we conclude the article with an outline of challenges and opportunities to be addressed in the future.
Motivation & Objective
- To provide a comprehensive overview of 30 years of research on code search, addressing evolving techniques and challenges.
- To analyze the types of queries supported by code search engines, including natural language and API-based queries.
- To examine preprocessing, indexing, retrieval, ranking, and pruning techniques used in code search systems.
- To identify open challenges and opportunities for future research in code retrieval and search engine design.
- To evaluate existing datasets and benchmarks, and to highlight the need for more realistic, large-scale, and action-oriented evaluation data.
Proposed method
- Systematic survey of 30 years of research on code search, focusing on full research papers from top conferences and journals (CORE A* or A ranked).
- Categorization of code search techniques by query type, preprocessing, indexing, retrieval, ranking, and pruning mechanisms.
- Analysis of learning-based approaches, including neural models for code retrieval and code-to-code search.
- Review of benchmark datasets such as CodeSearchNet, CodeXGLUE, CoSQA, and BigCloneBench, including their use in evaluating code search engines.
- Examination of challenges in model evaluation, particularly the risk of data leakage due to pre-training on public code corpora.
- Discussion of future directions, including query-less search, automatic clarification questions, and code completion in search interfaces.
Experimental results
Research questions
- RQ1What types of queries do modern code search engines support, and how do they handle natural language and API-based queries?
- RQ2How do code search engines preprocess and expand queries to improve retrieval accuracy?
- RQ3What are the dominant indexing and retrieval techniques used in code search, and how do they scale to large codebases?
- RQ4What strategies are used to rank and prune search results for better developer usability?
- RQ5What are the limitations of current benchmarks, and how can future datasets better reflect real-world developer behavior?
Key findings
- Code search has evolved into a mature research field with significant impact on real-world software development, supported by a wide range of techniques and systems.
- Learning-based models, especially those pre-trained on large code corpora, have become central to modern code search, improving retrieval performance.
- Benchmarks like CodeSearchNet and CodeXGLUE have enabled standardized evaluation, but there is a risk of data leakage when models are pre-trained on similar data.
- Natural language queries and API-based queries are increasingly supported, enabling developers to search using high-level specifications or examples.
- There is a growing need for benchmarks that include developer interaction data, such as result selection and code adaptation, to better reflect real-world usage.
- Future directions include query-less search, automatic clarification, and integrating code completion into search interfaces to reduce user effort.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.