python-3.x - 如何在弹性搜索中访问存储的二维浮点数组?
问题描述
index_body = {
"mappings": {
"properties": {
"question": {
"type": "text"
},
"question_vec": {
"type": "float",
},
"q_id": {
"type": "int"
}
}
}
}
这是我的索引体。在“question_vec”中,我传递了二维数组浮点数组,但在查询数据库时无法访问它,因为我的指标分数取决于它,RequestError(400, 'search_phase_execution_exception', 'runtime error')
这是示例 body_query,实际查询更复杂
s_body = {
"query": {
"script_score": {
"query": {
"match_all": {}
},
"script": {
"lang": "painless",
"source": """
int score = 100;
int len1 = (params.query_vector[0]).length;
int len2 = doc['question_vec'].length;
return doc['question_vec'][0][0];
"""
,
"params": {"query_vector": query_vec}
}
}
}
}
解决方案
推荐阅读
- python - 基类为抽象时调用基类ctor时出现pylint错误
- javascript - Telerik radcombobox 取消选择 OnClientCheckAllChecked 上的禁用项目
- python - 学习 Python 3 的艰难方式 Ex.23 - powershell 中未显示的字符
- android - Firebase 实时数据库中的子键问题仅在发布版本中
- javascript - 如何通过富文本编辑器使用 JavaScript 和 PHP 将带有编码 HTML 标签的数据插入数据库?
- excel - 如何添加第三个条件 .find
- python - 如何使用用户、密码和主机名在 python 中连接到 sqlite3 db
- networking - opensuse 飞跃没有网络但想安装 KDE
- android - ReactNative 中的 API 获取
- django - 如何将对象传递给 Django 中的模型字段?