【发布时间】:2021-09-21 01:39:41
【问题描述】:
我在 OrientDB 3.0.27 中有以下数据,其中一些值在 JSON 数组中,一些是字符串
{
"@type": "d",
"@rid": "#57:0",
"@version": 2,
"@class": "abc_class",
"user_name": [
"7/1 LIBOR Product"
],
"user_Accountability": [],
"user_Rollout_32_date": [],
"user_Brands": [
"AppNet"
],
"user_lastModificationTime": [
"2019-11-27 06:40:35"
],
"user_columnPercentage": [
"0.00"
],
"user_systemId": [
"06114a87-a099-0c30c60b49c4"
],
"user_lastModificationUser": [
"system"
],
"system_type": "Product",
"user_createDate": [
"2017-10-27 09:58:42"
],
"system_modelId": "bian_model",
"user_parent": [
"a12a41bd-af6f-0ca028af480d"
],
"user_Strategic_32_value": [],
"system_oeId": "06114a87-a099-0c30c60b49c4",
"user_description": [],
"@fieldTypes": "user_name=e,user_Accountability=e,user_Rollout_32_date=e,user_Brands=e,user_lastModificationTime=e,user_columnPercentage=e,user_systemId=e,user_lastModificationUser=e,user_createDate=e,user_parent=e,user_Strategic_32_value=e,user_description=e"
}
我尝试了以下查询:
select * from `abc_class ` where any() = ["AppNet"] limit 2;
select * from `abc_class ` where any() like '%a099%' limit 2;
上述两个查询都有效,因为它们尊重字段的数据类型。
我想运行包含查询,它将在任何数据类型(如字符串、数字、JSON 数组等)的任何字段中进行搜索,更像是 - 全文搜索。
select * from `abc_class ` where any() like '%AppNet%' limit 2;
上述查询不起作用,因为实际值在 JSON 数组中。尝试了filtering section documentation的几乎所有东西
如何利用现有数据实现全文搜索之类的功能?
编辑#1
现在做更多研究后,我至少可以将数组值转换为字符串,然后在其上运行 like 运算符,如下所示;
select * from `abc_class` where user_name.asString() like '%LIBOR%'
但是,使用 any().asString() 不会产生任何结果
select * from `abc_class` where any().asString() like '%LIBOR%'
如果上面的查询可以通过某种方式增强以将任何列查询为字符串,那么问题就可以解决了。
【问题讨论】:
标签: database where-clause orientdb document-database