
问题在于,Elasticsearch无法推断正确的类型。它认为字典中的每个键都是一个新字段(embedding.key)。因此,我们需要提供一个指定类型的映射。在我的情况下,在创建索引后使用Python中的elasticsearch库:
import requestsuri='http://localhost:9200/my_index/_mapping'json_body="""{ "properties": { "name": { "type": "keyword" }, "reference": { "type": "keyword" }, "jurisdiction": { "type": "keyword" }, "text": { "type": "text" }, "embedding": { "type": "sparse_vector" } }}""")headers = { 'Content-Type': 'application/json',}requests.put(uri, headers=headers, data=json_body)欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)