postgresql - 对 Cube 数据类型列执行 Postgresql 查询时出错
问题描述
我是 Postgesql 的新手。我创建了一个表,其中包含(Id integer, name text, url text, vector cube)
名为images
.
<->
现在我想使用(euclidean distance ) 运算符搜索 K 最接近新立方体变量的值。我的查询如下(我假设数据列是 3D):
Select *
from images
order by vector <-> cube(array[0.5, 0.3, 0.2])
limit 5
但是会出现以下错误:
ERROR: operator does not exist: cube <-> cube
LINE 1: Select * from test order by data <-> cube(array[0.5, 0.3, 0.2...
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
SQL state: 42883
Character: 38
请帮助我。谢谢。我正在使用 Ubuntu 16.04.6 LTS 和 Postgresql 版本 9.5.19。
我的表格和错误的屏幕截图附在下面:
解决方案
postgres 9.5 中的cube
扩展没有<->
操作符。你可以cube_distance
改用。以下是相关文档:
推荐阅读
- batch-file - 将递增计数器连接到批处理文件中的字符串变量
- reference - 如何将 Option<&T> 转换为 Option
以 Rust 中最惯用的方式? - python - PyQtChart 不显示数据
- java - string.equalsIgnoreCase(object.string) 与 object.string.equalsIgnoreCase(string) 之间的区别
- mongodb - MongoDB,数组,子元素,计数,百分比
- javascript - 如何让我的每个测验问题及其在不同页面中的选择由 axios 做出反应
- kubernetes - 应该允许每个节点启动 30 个 pod
- loopbackjs - Loopback:发送额外的键/值对作为响应
- c# - 如何将 c# asp-format 标记中的小数格式化为 2 个小数点,如果它是 int,则不使用尾随零?
- python - 如何使用字典将多个值作为一个键