将稀疏向量添加为Elasticsearch中的字段

将稀疏向量添加为Elasticsearch中的字段,第1张

将稀疏向量添加为Elasticsearch中的字段

问题在于,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)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4944621.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-13
下一篇2022-11-13

发表评论

登录后才能评论

评论列表(0条)

    保存