Skip to content

Implement an option to retrieve search results from the Ballerina Central #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nipunayf
Copy link
Contributor

@nipunayf nipunayf commented Jul 17, 2025

Purpose

The current search implementation is limited to the local index, which is a snapshot of packages inballerina and ballerinax. The searchCentral flag is added to the search API, enabling users to search the central repository instead of the local index, thereby broadening the results to include user-published packages.

Addresses wso2/product-ballerina-integrator#758

Remarks

  • The central lacks dedicated APIs for searching functions and types separately (not affected for the connections as there is a separate endpoint for it). As a result, the LS must use the search-suggestions API for all searches and filter results based on kind. This approach affects pagination since we cannot guarantee that we'll meet the specified limit in the request.
    • One approach would be to query the central until we fetch enough results to meet the limit. Not only that this is an inefficient approach, but also it would require a complex agreement between the LS and the extension to dynamically adjust the offset.
    • The sustainable solution would be to implement additional APIs in the central to support searching based on function kinds. However, this would be a waste of effort since providing APIs for streaming would be a better use of resources.
  • The ideal solution is to first query the local index and stream results from the central repository in the background. This approach keeps the search fast and the UI responsive, while still providing a broad range of results. However, it requires additional APIs from Ballerina Central.

Samples

Connection Search

Screen.Recording.2025-07-17.at.7.47.53.PM.mov

Function Search

Screen.Recording.2025-07-17.at.7.56.23.PM.mov

@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 16:56
@nipunayf nipunayf requested a review from KavinduZoysa as a code owner July 17, 2025 16:56
Copy link
Contributor

@Copilot 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 support for searching Ballerina Central when the searchCentral flag is set, augmenting existing local index searches with remote results.

  • Introduce a searchCentral boolean flag in SearchCommand and update execute() to branch based on it
  • Implement searchCentral() in TypeSearchCommand, FunctionSearchCommand, ConnectorSearchCommand, and NPFunctionSearchCommand
  • Add io.ballerina.centralconnector dependency in module-info and Gradle build

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
flow-model-generator-core/src/main/java/module-info.java Add io.ballerina.centralconnector module requirement
TypeSearchCommand.java Import central connector, remove old includeAllResults param, add searchCentral()
SearchCommand.java Add searchCentral field, default constant, constructor parsing, and update execute() logic
NPFunctionSearchCommand.java Override searchCentral() to delegate to search()
FunctionSearchCommand.java Import central connector, implement searchCentral() for functions
ConnectorSearchCommand.java Import connector response, refactor local builds, implement searchCentral()
build.gradle Add flow-model-central-client project dependency

@nipunayf nipunayf force-pushed the add-central-search branch from 3438b77 to 8f40ffe Compare July 17, 2025 17:14
@nipunayf nipunayf force-pushed the add-central-search branch from 8f40ffe to 505c985 Compare July 17, 2025 17:15
@nipunayf nipunayf marked this pull request as draft July 18, 2025 09:41
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.

1 participant