Code Search Result Ranking via Include-Tree Context

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In large code bases, text editor applications like Emacs return multiple results for a given search query, making it difficult for developers to find the appropriate file location for a tag definition, as the number of results grows with the code base size.

Innovation Solution

An index is built that includes the file name, path relative to a root directory, and an include-tree representation for each source file, allowing search queries to be ranked based on the current context and include-tree, with results communicated using an s-expression protocol to narrow down relevant information.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If a traditional TAGS file indexing approach is used, then the system can provide complete search results for tag definitions, but the number of results increases significantly in large code bases, making it difficult for developers to find the appropriate file location

Engineering Contradiction:
Improvecompleteness of search resultsVSAvoiddifficulty of finding appropriate file location
Core Design Contradiction:
ReliabilityVSEase of operation

Solution Approach 1:

The patent applies local quality by differentiating the importance of different search results based on their contextual relevance. Results are ranked according to the include-tree relationship, where tags defined in files that include the current file are given higher priority. This creates a localized view of relevant results rather than treating all results equally, making it easier for developers to find the most appropriate file location first.

Inventive Principle:
Principle #3Local quality

Solution Approach 2:

The patent changes the ranking parameter from simple match-based ordering to a context-aware ranking system that considers the include-tree relationship. By introducing a new parameter (contextual relevance based on include-tree) and changing how results are ordered, the system maintains completeness while improving ease of operation by presenting the most relevant results first.

Inventive Principle:
Principle #35Parameter changes

2Adaptability or versatility

If the code base grows larger, then more functionality and tags are available to search, but the number of search results increases, increasing the time and effort required to sift through results

Engineering Contradiction:
Improveavailability of tags to searchVSAvoidtime to sift through results
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

The patent applies preliminary action by pre-building and storing the include-tree relationship for each file during indexing. This contextual information is prepared in advance and stored in the index structure, allowing the search system to quickly determine relevance without performing complex analysis during the actual search operation. This reduces the time required to process and rank results as the code base grows.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces a new ranking parameter based on the include-tree relationship that allows results to be ordered by contextual relevance. This parameter change enables the system to maintain adaptability with growing code bases while reducing time loss by presenting the most relevant results first, rather than requiring developers to sift through all results equally.

Inventive Principle:
Principle #35Parameter changes

3Device complexity

If all tag definitions are returned equally, then the search is simple to implement, but developers cannot efficiently identify the most relevant results without manually examining each one

Engineering Contradiction:
Improvesimplicity of search implementationVSAvoidefficiency of finding tag definitions
Core Design Contradiction:
Device complexityVSProductivity

Solution Approach 1:

The patent changes the result ordering parameter from simple match-based ranking to context-aware ranking based on include-tree relationships. This parameter change improves productivity by automatically prioritizing the most relevant results, allowing developers to find tag definitions more efficiently without significantly increasing implementation complexity, as the ranking logic is integrated into the search process.

Inventive Principle:
Principle #35Parameter changes

Solution Approach 2:

The patent implements feedback by using the include-tree relationship to inform the ranking of search results. The system feedback mechanism automatically identifies which results are most relevant based on the contextual relationship between the current file and files containing tag definitions, presenting the most useful results first without requiring manual intervention from developers.

Inventive Principle:
Principle #23Feedback

Data Source

PatentUS7613693B1Preferential ranking of code search results
Publication Date: 2009.11.03 GOOGLE LLC
  • US7613693B1 patent drawing
  • US7613693B1 patent drawing
  • US7613693B1 patent drawing

AI summary

TAG files are generated on a client and communicated to a server. The TAGS files are indexed and loaded into memory on the server. Search requests are run against the index and files that contain tags that satisfy the search request are ranked. The ranking is based on an include-tree of the file that contains the tag, the relative directory distance of the file containing the tag from the current context, or by using the numbers of levels of inclusion needed to reach a tag that satisfies the query. In some implementations, an extensible protocol is used to communicate the search queries and files that contain tags that satisfy the search query.