我有一个列表docid
并想检查它们是否存在于 Vespa 中。如果是,则返回 that 的特定字段docid
。目前,我正在按顺序执行此操作。Python中的示例代码:
import requests
doc_urlbase = 'http://localhost:8080/document/v1/test/test'
docid_list = [1,2,3,4,5]
for docid in docid_list:
doc_url = '{}/{}'.format(doc_urlbase, i)
req = requests.get(doc_url)
if req.status_code == 200:
# docid is in Vespa, save the field value
else:
# display not found
我希望有更好的方法来做到这一点,并返回一个数组/映射作为结果。就像是:
Query given:
docid_list = [1,2,3,4,5]
Return:
{
1: "field value",
2: "field value",
3: "", # not in Vespa
4: "field value",
5: "field value",
}
谢谢!