Exclude vectors from response
This commit is contained in:
@@ -286,7 +286,7 @@ async def vector_search_topics(
|
||||
detail=f"Failed to encode query text: {exc}"
|
||||
)
|
||||
|
||||
# 2. Query Elasticsearch
|
||||
# 2. Query Elasticsearch using vector similarity search
|
||||
|
||||
body = {
|
||||
"knn": {
|
||||
@@ -294,6 +294,9 @@ async def vector_search_topics(
|
||||
"query_vector": query_vector,
|
||||
"k": limit,
|
||||
"num_candidates": 100
|
||||
},
|
||||
"_source": {
|
||||
"excludes": ["vector"] #remove vectors
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,13 +317,7 @@ async def vector_search_topics(
|
||||
hits = raw_results.get("hits", {}).get("hits", [])
|
||||
total = len(hits)
|
||||
|
||||
results = []
|
||||
for hit in hits:
|
||||
source = hit.get("_source", {})
|
||||
# Remove vector field (dont send to frontend)
|
||||
if "vector" in source:
|
||||
del source["vector"]
|
||||
results.append(source)
|
||||
results = [hit.get("_source", {}) for hit in hits]
|
||||
|
||||
data = {
|
||||
"meta": {
|
||||
|
||||
Reference in New Issue
Block a user