Skip to content

Comments

Include search functionality for type search in local modules#429

Merged
nipunayf merged 4 commits intoballerina-platform:1.2.xfrom
nipunayf:submodule-type-search
Oct 25, 2025
Merged

Include search functionality for type search in local modules#429
nipunayf merged 4 commits intoballerina-platform:1.2.xfrom
nipunayf:submodule-type-search

Conversation

@nipunayf
Copy link
Contributor

Purpose

This PR updates the existing submodule type search to include a relevance-based sorting mechanism. Each search result is now assigned a relevance score that determines its display order.

Since the respective types are not indexed, there is no inverted index available to calculate the search rank. As an alternative, the relevance score is computed manually to mimic the ranking behavior of SQLite FTS search.

Fixes wso2/product-ballerina-integrator#1601

Relevance Score Calculation:

  1. Exact Match (100pts): Assigns the highest possible score if the type name perfectly matches the query.
  2. Prefix Match (50pts): Awards a high score if the type name starts with the query.
  3. Substring Match (up to 10pts): If the query appears within the type name, it assigns a score that decreases as the match position moves further from the start.
  4. Fuzzy Match (up to 5pts): As a fallback, it uses the Levenshtein distance to score based on similarity, tolerating typos.
  5. Abbreviation Bonus (3pts): Adds points if the query matches the CamelCase initials of the type name (e.g., "HC" for "HttpClient").
  6. Description Bonus (2-3pts): Adds extra points if the query is found in the type's description, with a higher bonus if it's at the beginning.

Copilot AI review requested due to automatic review settings October 25, 2025 10:07
@nipunayf nipunayf changed the base branch from main to 1.2.x October 25, 2025 10:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds search functionality for types in local modules with a relevance-based scoring mechanism to improve search result ordering. The scoring system includes exact match, prefix match, substring match, fuzzy match, abbreviation matching, and description-based matching. Additionally, the PR updates dependency versions for HTTP and JSON data libraries, fixes primitive type handling in reference types, and includes test resources for validating the search functionality.

Key Changes

  • Implemented relevance-based type search scoring for local module types
  • Updated HTTP library version from 2.14.6 to 2.14.7
  • Updated JSON data library version from 1.1.1 to 1.1.3
  • Enhanced primitive type handling to support additional integer subtypes (Signed8/16/32, Unsigned8/16/32) and new types (byte, string:Char, regexp:RegExp)

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ReferenceType.java Refactored primitive type handling, added support for additional int subtypes, byte, string:Char, and regexp types
gradle.properties Updated stdlib versions for HTTP (2.14.7) and JSON data (1.1.3) libraries
Test resource files (nested/nested_editing/*) Added test fixtures for local module type usage scenarios
Test resource files (search/config/types/*) Added comprehensive search test cases covering exact match, prefix match, substring match, case insensitive, description match, special characters, and no match scenarios
Test resource files (embedding/model provider configs) Fixed typo in label from "Open Model Provider" to "OpenAI Model Provider"
DataMapperDefinitionBuilder.java Minor formatting cleanup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@NipunaRanasinghe NipunaRanasinghe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nipunayf nipunayf merged commit 931d3a1 into ballerina-platform:1.2.x Oct 25, 2025
3 checks passed
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.

The types are not filtered by the query for local modules

2 participants