Hybrid search combines search methods in one query. A search application might use text or other indexed fields alongside vector similarity, depending on its data and requirements. In Azure AI Search, a hybrid request runs full-text and vector queries against an index containing searchable text and embeddings, then returns one result set using reciprocal rank fusion. section 8.5 section 8.2
A Redis example starts with a user question, converts it to an embedding, and searches indexed blog posts. Its `hybrid_search()` function combines an indexed-field expression with a K-nearest-neighbors query over `@embedding`, requests fields such as title and content, sorts by `vector_score`, and limits the results with `top_k`. The shown call uses `hybrid_fields="*"`; it demonstrates the query structure without specifying a selective text or category condition. section 8.5
Listing 8.8 Searching using Redis
def hybrid_search(query_vector, client, top_k=3, hybrid_fields="*"):
base_query = f"{hybrid_fields}=>
[KNN {top_k}
@embedding $vector AS vector_score]" #1
query = Query(base_query).return_fields(
"url", #2
"title", #2
"publish_date", #2
"description", #2
"content", #2
"vector_score").sort_by("vector_score").dialect(2) #3
try:
results = client.ft("posts").search(
query, query_params={"vector": query_vector}) #4
except Exception as e:
print("Error calling Redis search: ", e)
return None
if results.total == 0:
print("No results found for the given query vector.")
return None
return results
# Connect to the Redis server
conn = redis.Redis(...)
query = input("Enter your query: ") #5
print("Vectorizing query...")
query_vector = get_embedding(query) #6
query_vector = np.array(query_vector).astype( #7
np.float32).tobytes()
print("Searching for similar posts...")
results = hybrid_search(query_vector, conn) #8
if results:
print(f"Found {results.total} results:")
for i, post in enumerate(results.docs):
score = 1 - float(post.vector_score)
print(post.content)
else:
print("No results found")
The Redis listing shows where an indexed-field expression, vector KNN clause, returned fields, score ordering, and result limit enter the query. section 8.5
For retrieval-augmented chat, the matching post chunks become context for an LLM prompt alongside the original question. Choose the search methods and fields to fit the information being queried. For larger enterprise workloads, Azure AI Search offers managed scaling and security features, including encryption and role-based access control; its reciprocal-rank-fusion result assembly is specific to the Azure implementation described here. section 8.6 section 8.2







