Skip to content

Add support for fts inside extension #400

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 2 commits into
base: development
Choose a base branch
from

Conversation

prajwal-pai77
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@lokesh-couchbase lokesh-couchbase left a comment

Choose a reason for hiding this comment

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

Some minor comments.
1 major is about having a function which tells if search service is present or not

@@ -357,6 +357,18 @@
"SQL++"
],
"configuration": "./language/language-configuration.json"
},

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove extra space in package.json

"SEARCH"
],
"configuration": "./language/language-configuration.json"

Copy link
Collaborator

Choose a reason for hiding this comment

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

space

"command": "vscode-couchbase.runSearch",
"key": "ctrl+shift+e",
"mac": "cmd+shift+e",
"when": "(editorLangId == cbs.json || resourceFilename =~ /.cbs.json$/) && !isKVCluster"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We will have to add another condition stating isSearchService. Because by default, search service is not mandatory

Copy link
Collaborator

Choose a reason for hiding this comment

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

The 2 icons are very different

Comment on lines +19 to +23
if (result?.indexDef instanceof Uint8Array || result?.indexDef instanceof Uint16Array || result?.indexDef instanceof Uint32Array) {
vscode.window.showInformationMessage("Unable to open Index definition: It is not a valid JSON", { modal: true });
return false;
}
const uri = vscode.Uri.parse(
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this the correct way of confirming it is valid json file?

Comment on lines +36 to +37
vscode.window.showInformationMessage("Unable to open Index definition: It is not a valid JSON ", { modal: true });
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Print error message as well, so that detailed debugging is possible here. Use logger.error for that

Comment on lines +700 to +720
const openSearchWorkbenchCommand = vscode.commands.registerCommand(Commands.openSearchWorkbench, async (searchIndexNode: SearchIndexNode) => {
const connection = Memory.state.get<IConnection>(Constants.ACTIVE_CONNECTION);
if (!connection) {
vscode.window.showErrorMessage("No active connection available.");
return;
}

currentSearchIndexNode = searchIndexNode;
currentSearchWorkbench = searchWorkbench;

searchWorkbench.openSearchWorkbench(searchIndexNode, memFs);

const editorChangeSubscription = vscode.window.onDidChangeActiveTextEditor(async (editor) => {
if (editor && editor.document.languageId === "searchQuery") {
await handleSearchContextStatusbar(editor, searchIndexNode, searchWorkbench, globalStatusBarItem);
}
});
context.subscriptions.push(editorChangeSubscription);

});
context.subscriptions.push(openSearchWorkbenchCommand);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we shift this to a new file?

Comment on lines +53 to +54
if (!hasQueryService(connection?.services) || filterDocumentsType !== "query") {
rowCount = KVCollectionCount.get(`kv_collection_item_count-${this.bucketName}-${this.scopeName}-${collection.name}`) ?? 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will need to check for search service as well wherever required

Comment on lines +44 to +64
// get all search indexes
const connection = getActiveConnection();
if (!connection){

return []
}
const searchIndexesManager = connection?.cluster?.searchIndexes();
const ftsIndexes = await searchIndexesManager?.getAllIndexes();
const bucketIndexes = ftsIndexes?.filter(index => index.sourceName === this.bucketName);
if (bucketIndexes === undefined) {
return [];
}
const searchIndexChildren: INode[] = bucketIndexes.map((searchIndex) =>
new SearchIndexNode(
searchIndex.name,
this.bucketName,
this.scopeName,
searchIndex.name
)


Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on search service present, Otherwise you may show an information node

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.

2 participants