Couchbase server filtering

“I want to filter and search the permission section in Couchbase.”
“I want to search for content that only contains the values in this list: ex,[1,2,3,4,5].”
Here is my code

from couchbase.cluster import Cluster
from couchbase.options import ClusterOptions
from couchbase.auth import PasswordAuthenticator
from couchbase.exceptions import CouchbaseException
import as search
from couchbase.options import SearchOptions
from couchbase.vector_search import VectorQuery, VectorSearch
import csv
import json
from openai import OpenAI


cluster = Cluster(
bucket = cluster.bucket("my_bucket")

scope = bucket.scope("my_scope")

search_index = "search-index"
    vector = client.embeddings.create(input = [question], model="text-embedding-3-small").data[0].embedding
    search_req = search.SearchRequest.create(search.MatchQuery("['1','2','3']")).with_vector_search(
        VectorSearch.from_vector_query(VectorQuery('title_body_vector', vector, num_candidates=5)))
        # Change the limit value to return more results. Change the fields array to return different fields from your Search index.
    result =, search_req, SearchOptions(limit=13,fields=["authority"]))
    for row in result.rows():
        print("Found row: {}".format(row))
    print("Reported total rows: {}".format(
except CouchbaseException as ex:
    import traceback

Could you please explain more about your query?

I am working with Couchbase and OpenAI to perform a vector search combined with filtering specific permissions in a document. My goal is to filter documents where the authority field contains at least one of the specified values (e.g., [“1”, “2”, “3”]) and then perform a vector search on those filtered documents.

Here is a detailed explanation of what I want to achieve:

  1. Filtering: I want to filter documents where the authority field, which is a list of strings, contains at least one value from my specified list [“1”, “2”, “3”].
  2. Vector Search: After filtering, I want to use OpenAI’s vector embeddings to perform a vector search within the filtered documents.