1 個回答
- 最新
- 最多得票
- 最多評論
0
I am facing the same problem, and I found a workaround. Just prepend a "$match" statement to your query. This way:
mycoll.insert_many([
{"color": "blue", "vectorField": [0.82421875, -0.6953125]},
{"color": "red", "vectorField": [0.82421875, -0.6953125]},
{"color": "red", "vectorField": [0.05883789, -0.02038574]},
{"color": "red", "vectorField": [0.2, 0.6]},
{"color": "green", "vectorField": [-0.020385742, 0.32421875]}])
query = { "$search": { "vectorSearch": { "vector": [0.82421875, -0.6953125], "path": 'vectorField', "similarity": 'euclidean', "k": 2}}}
query_filter = {
"$match": {
"color":{ "$eq": "red"}
}
}
c = mycoll.aggregate([query_filter,query])
print(list(c))
I played a bit with this and it seems to work. I'll let mongo experts maybe comment if there is a better way.
已回答 42 分鐘前
相關內容
- AWS 官方已更新 9 個月前
- AWS 官方已更新 9 個月前