Skip to content

Add fractional search feature to ripgrep_search tool#944

Draft
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
codegen-fractional-search-feature
Draft

Add fractional search feature to ripgrep_search tool#944
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
codegen-fractional-search-feature

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Mar 22, 2025

This PR adds a new fractional_search feature to the ripgrep_search tool. When enabled, this feature will automatically search for individual words from a query if the full query returns no results.

Changes:

  1. Added a new fractional_search parameter to the search function in search.py (default: False)
  2. Modified both _search_with_ripgrep and _search_with_python to implement the fractional search logic:
    • If no results are found for the full query and fractional_search=True:
      • Split the query into individual words (filtering out very short words)
      • Search for each word individually
      • Combine results while avoiding duplicates
  3. Updated the SearchInput model to include the new parameter
  4. Updated the RipGrepTool class to pass the parameter to the search function
  5. Renamed the tool from "search" to "ripgrep_search" for clarity

This feature will help improve search results when exact phrases aren't found in the codebase, making it easier to discover relevant code without having to manually try different search terms.

Testing:

The implementation includes:

  • Proper handling of duplicate results when combining individual word searches
  • Skipping very short words (less than 3 characters) to avoid noise
  • Maintaining the original search behavior when fractional_search is disabled
  • Support for both ripgrep and Python-based search implementations

💻 View my work • React 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants