Vector Search with JavaScript: couchbaseQuery is always the empty string (page 181)

Hi @hummusonrails,

I have created a capella account version 7.6.6.

I have started the server with current main branch.

When running the following query

 curl http://localhost:4000/api/search -X POST \
   -H "Content-Type: application/json" \
   -H "Accept: application/json" \
   -d '{"query":"your search text here"}'

then the couchbaseQuery text generated from build() returns an empty string.

Digging into it, the query is missing a queryType and therefore the build does not perform any building but returns the empty string.

Any idea why this happens?
Thanks
Markus

Hey there,

In the original flow in the sample application in the repo, /api/search was wired to the Ottoman query builder example, which generates SQL++ and not vector or full-text queries. Without a queryType, .build() just returns an empty string, that’s expected for that path.

I updated the repository example to be more straightforward going forward though. The updated flow now routes /api/search through the performSearch service. This is the part of the repo that uses the Couchbase SDK’s scope.search() API with a VectorSearch request, which is the intended way to run vector searches in this sample.

For it to return meaningful results, you’ll still need:

  • Documents in your Capella bucket/scope with an embedding array field
  • A Capella Vector Search index on that field

This sample is meant to illustrate how vector search fits into an app’s flow, not to be a complete production setup. If you want to take it further, the Couchbase docs walk through the full Capella + Node.js SDK setup:

With the current controller in place, once your index and embeddings are ready, /api/search will execute a proper vector search against Capella and return ranked results.

All the best,

Ben