Hi @nithishr,
Thank you so much for looking into this. I really appreciate the help. After a long debugging session, we have managed to solve all environment, configuration, and application startup issues, but the vector search still returns 0 documents.
As requested, here is the index definition, a sample document, and the Python code snippet we are trying.
1. Index Definition (passeios_v2_idx
)
This is the JSON definition used to create a new index from scratch on a completely new and empty bucket/scope/collection.
JSON{ "name": "passeios_v2_idx", "type": "fulltext-index", "params": { "doc_config": { "docid_prefix_delim": "", "docid_regexp": "", "mode": "scope.collection.type_field", "type_field": "type" }, "mapping": { "default_analyzer": "standard", "default_datetime_parser": "dateTimeOptional", "default_field": "_all", "default_mapping": { "dynamic": false, "enabled": false }, "default_type": "_default", "docvalues_dynamic": false, "index_dynamic": true, "store_dynamic": true, "type_field": "_type", "types": { "dados.conteudo": { "dynamic": false, "enabled": true, "properties": { "embedding": { "enabled": true, "dynamic": false, "fields": [ { "dims": 384, "index": true, "name": "embedding", "similarity": "cosine", "type": "vector" } ] }, "text": { "enabled": true, "dynamic": false, "fields": [ { "analyzer": "standard", "index": true, "name": "text", "store": true, "type": "text" } ] } } } } }, "store": { "indexType": "scorch" } } }
2. Sample Document
This is an example of one of the 18 documents that are being successfully inserted into the xu_passeios.dados.conteudo
collection. The embedding
field contains a valid list of 384 float values generated by the all-MiniLM-L6-v2
model.
JSON{ "id": "doc_4", "text": "Fernando de Noronha - Pacote Completo 7 dias: Inclui voos de Recife, hospedagem na Pousada Maravilha, mergulho com cilindro, trilha do Atalaia, passeio de barco para ver golfinhos, jantar no Mergulhão. Preço: R$ 8.500 por pessoa (alta temporada) / R$ 6.200 (baixa temporada).", "embedding": [ -0.08839886, 0.09436358, -0.0045749, "... 381 more float values ..." ], "metadata": { "categoria": "ofertas", "tags": [ "fernando", "preços", "mergulho", "hospedagem" ] }, "type": "dados.conteudo" }
3. Python Code Snippet (The Search Function)
This is the final version of the search function from my CouchbaseVectorStore
class. It uses the exact syntax recommended in the official Couchbase documentation that I found.
Note: Config.INDEX_NAME
correctly resolves to 'passeios_v2_idx'
.
`Pythonfrom config import Config
from couchbase.exceptions import CouchbaseException
from couchbase.options import SearchOptions
import couchbase.search as search
from couchbase.search import SearchScanConsistency
from couchbase.vector_search import VectorSearch, VectorQuery
def search_documents(self, query_text: str, limit: int = 4) → list:
“”“Performs a vector search using the officially documented syntax.”“”
try:
# This function correctly generates a 384-dimension vector
query_embedding = self._generate_embedding(query_text)
if not query_embedding:
return
search_index_name = Config.INDEX_NAME
# Using the exact syntax from the documentation
vector_query = VectorQuery("embedding", query_embedding, num_candidates=limit + 10)
vector_search = VectorSearch.from_vector_query(vector_query)
search_request = search.SearchRequest.create(search.MatchNoneQuery()).with_vector_search(vector_search)
result = self.scope.search(
index=search_index_name,
request=search_request,
options=SearchOptions(
limit=limit,
fields=["text"],
scan_consistency=SearchScanConsistency.REQUEST_PLUS
)
)
documents = [row.fields for row in result.rows() if row.fields]
logger.info(f"✅ Vector search performed for '{query_text}'. Found {len(documents)} documents.")
return documents
except Exception as e:
logger.error(f"❌ An unexpected error occurred during search: {e}", exc_info=True)
return []
`
Summary of the problem: My application startup logic now correctly waits for the index to report all 18 documents as processed. The application then runs the search_documents
function with a specific query like “Noronha”. The function executes without any Python exceptions, but the result from Couchbase consistently reports 0 documents found.
Any insight you have would be greatly appreciated. Thank y