Hi, I want to know how can I filtering vector search

“I want to first filter by a specific field for a word, and then perform a vector search.”
“For example, to be viewable only by people with a specific authority.”
this is my code How can I change?

try:
    vector = client.embeddings.create(input = [question], model="text-embedding-3-small").data[0].embedding
    search_req = search.SearchRequest.create(search.TermQuery("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 = scope.search(search_index, search_req, SearchOptions(limit=13,fields=["authority"]))
    for row in result.rows():
        print("Found row: {}".format(row))
    print("Reported total rows: {}".format(
        result.metadata().metrics().total_rows()))
except CouchbaseException as ex:
    import traceback
    traceback.print_exc()
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.