Elastic Search对象是sku查询skuid=101
以下是使用Elasticsearch进行查询的示例代码:
from elasticsearch import Elasticsearch
# 创建Elasticsearch客户端
es = Elasticsearch()
# 构建查询条件
query = {
"query": {
"match": {
"id": "101"
}
}
}
# 执行查询
result = es.search(index="your_index_name", body=query)
# 输出结果
for hit in result['hits']['hits']:
print(hit['_source'])
其中,your_index_name是你要查询的索引名称。如果你的sku数据已经被索引到Elasticsearch中,那么上述代码会输出id为101的sku对象。如果没有输出结果,那么可能是查询条件不正确或者数据没有被正确索引。
原文地址: https://www.cveoy.top/t/topic/eGut 著作权归作者所有。请勿转载和采集!