OrientDB:按整个嵌入字段值筛选
我要在OrientDB中插入一个带有嵌入字段的记录,然后使用过滤器查询该记录:OrientDB:按整个嵌入字段值筛选,orientdb,orientdb3.0,Orientdb,Orientdb3.0,我要在OrientDB中插入一个带有嵌入字段的记录,然后使用过滤器查询该记录: insert into MyClass set embeddedField = {'@type': 'd', 'id': 1} 效果很好,而且 select from MyClass 返回我添加的记录。但当我为embeddedField添加where with filter时,没有得到任何结果: select from MyClass where embdeddedField = {'@type': 'd', '
insert into MyClass set embeddedField = {'@type': 'd', 'id': 1}
效果很好,而且
select from MyClass
返回我添加的记录。但当我为embeddedField添加where with filter时,没有得到任何结果:
select from MyClass where embdeddedField = {'@type': 'd', 'id': 1}
我认为这可能是因为Orient在嵌入的文档中添加了@version字段,所以我尝试使用version进行搜索:
select from MyClass where embdeddedField = {'@type': 'd', '@version': 0, 'id': 1}
但还是没有结果
问题:知道如何按整个文档过滤嵌入字段吗?无需按嵌入文档的每个字段进行明确筛选:
select from MyClass
where embdeddedField.id = 1
and embdeddedField.field2 = val2
and embeddedField.field3 = val3
因为以下几个原因,我希望将整个对象作为单个查询参数传递:
select from MyClass where embdeddedField = ?
这是因为提供的散列被转换为嵌入式类 也许可以看看ActiveOrientWiki 解释: 以一个类
base
为例,这里有一个具有两个属性(无模式)的文档
并向其中添加现有文档
(0..9)。每个都有|
base\u record=base.create标签:b,第一个\u列表:[]
(0..9).每个{c | base_record.first_list创建顶点基内容{“label”:0,“first_list”:[]}
信息->创建顶点优先列表内容{“标签”:0}
INFO->update#136:0 set first_list=first_list |[#147:0]在@this之后返回
然后链接被嵌入,记录看起来像
=> #<Base:0x00000000041a60e0 @metadata={:type=>"d", :class=>"base", :version=>11, :fieldTypes=>"first_list=z", :cluster=>129, :record=>1},
@attributes={:first_list=>["#149:1", "#150:1", "#151:1", "#152:1", "#145:2", "#146:2", "#147:2", "#148:2", "#149:2", "#150:2"], :label=>"1"}>
=>#“d”,:class=>“base”,:version=>11,:fieldTypes=>“first\u list=z”,:cluster=>129,:record=>1},
@属性={:第一个列表=>[“#149:1”,“#150:1”,“#151:1”,“#152:1”,“#145:2”,“#146:2”,“#147:2”,“#148:2”,“#149:2”,“#150:2”,“#150:2”,“标签=>”1}>
如果展开列表项,可以查询“@type”
如果添加没有rid的文档,同样的情况也会发生
( 0..9 ).each {|c| base_record.first_list << FirstList.new( label: c ) }
20.04.(12:53:59) INFO->update #130:2 set first_list = first_list || [{ @type: 'd' ,@class: 'first_list' ,label: 0 }] return after @this
INFO->CREATE VERTEX base CONTENT {"label":"c","first_list":[]}
'#130:2'.expand
=> #<Base:0x00000000043927a0 @metadata={:type=>"d", :class=>"base", :version=>11, :fieldTypes=>"first_list=z", :cluster=>130, :record=>2},
@attributes={:first_list=>["#151:12", "#152:12", "#145:13", "#146:13", "#147:13", "#148:13", "#149:13", "#150:13", "#151:13", "#152:13"], :label=>"c"}>
(0..9).每个{c| base|u record.first|u list update#130:2 set first|u list=first|list |[{@type:'d',@class:'first|u list',label:0}]在@this之后返回
信息->创建顶点基础内容{“标签”:“c”,“第一个列表”:[]}
#130:2.展开
=>#“d”,:class=>“base”,:version=>11,:fieldTypes=>“first_list=z”,:cluster=>130,:record=>2},
@属性={:第一个列表=>[“#151:12”,“#152:12”,“#145:13”,“#146:13”,“#147:13”,“#148:13”,“#149:13”,“#150:13”,“#151:13”,“#152:13”,“标签=>“c”}>
如果省略类名,则只会更改rid的范围
INFO-> update #132:2 set first_list = first_list || { @type: 'd' ,label: 0 } return after @this
=> [#<Base:0x0000000003a26fb8 @metadata={:type=>"d", :class=>"base", :version=>3, :fieldTypes=>"first_list=z", :cluster=>132, :record=>2},
@attributes={:first_list=>["#3:0"], :label=>"d"}>]
INFO->update#132:2 set first_list=first_list |{@type:'d',label:0}在@this之后返回
=>[#“d”,:class=>“base”,:version=>3,:fieldTypes=>“first\u list=z”,:cluster=>132,:record=>2},
@attributes={:first_list=>[“#3:0”],:label=>“d”}>]
在任何情况下,对
@type
的查询都会失败,这是因为提供的哈希被转换为嵌入式类
也许可以看看ActiveOrientWiki
解释:
以一个类base
为例,这里有一个具有两个属性(无模式)的文档
并向其中添加现有文档
(0..9)。每个都有|
base\u record=base.create标签:b,第一个\u列表:[]
(0..9).每个{c | base_record.first_list创建顶点基内容{“label”:0,“first_list”:[]}
信息->创建顶点优先列表内容{“标签”:0}
INFO->update#136:0 set first_list=first_list |[#147:0]在@this之后返回
然后链接被嵌入,记录看起来像
=> #<Base:0x00000000041a60e0 @metadata={:type=>"d", :class=>"base", :version=>11, :fieldTypes=>"first_list=z", :cluster=>129, :record=>1},
@attributes={:first_list=>["#149:1", "#150:1", "#151:1", "#152:1", "#145:2", "#146:2", "#147:2", "#148:2", "#149:2", "#150:2"], :label=>"1"}>
=>#“d”,:class=>“base”,:version=>11,:fieldTypes=>“first\u list=z”,:cluster=>129,:record=>1},
@属性={:第一个列表=>[“#149:1”,“#150:1”,“#151:1”,“#152:1”,“#145:2”,“#146:2”,“#147:2”,“#148:2”,“#149:2”,“#150:2”,“#150:2”,“标签=>”1}>
如果展开列表项,可以查询“@type”
如果添加没有rid的文档,同样的情况也会发生
( 0..9 ).each {|c| base_record.first_list << FirstList.new( label: c ) }
20.04.(12:53:59) INFO->update #130:2 set first_list = first_list || [{ @type: 'd' ,@class: 'first_list' ,label: 0 }] return after @this
INFO->CREATE VERTEX base CONTENT {"label":"c","first_list":[]}
'#130:2'.expand
=> #<Base:0x00000000043927a0 @metadata={:type=>"d", :class=>"base", :version=>11, :fieldTypes=>"first_list=z", :cluster=>130, :record=>2},
@attributes={:first_list=>["#151:12", "#152:12", "#145:13", "#146:13", "#147:13", "#148:13", "#149:13", "#150:13", "#151:13", "#152:13"], :label=>"c"}>
(0..9).每个{c| base|u record.first|u list update#130:2 set first|u list=first|list |[{@type:'d',@class:'first|u list',label:0}]在@this之后返回
信息->创建顶点基础内容{“标签”:“c”,“第一个列表”:[]}
#130:2.展开
=>#“d”,:class=>“base”,:version=>11,:fieldTypes=>“first_list=z”,:cluster=>130,:record=>2},
@属性={:第一个列表=>[“#151:12”,“#152:12”,“#145:13”,“#146:13”,“#147:13”,“#148:13”,“#149:13”,“#150:13”,“#151:13”,“#152:13”,“标签=>“c”}>
如果省略类名,则只会更改rid的范围
INFO-> update #132:2 set first_list = first_list || { @type: 'd' ,label: 0 } return after @this
=> [#<Base:0x0000000003a26fb8 @metadata={:type=>"d", :class=>"base", :version=>3, :fieldTypes=>"first_list=z", :cluster=>132, :record=>2},
@attributes={:first_list=>["#3:0"], :label=>"d"}>]
INFO->update#132:2 set first_list=first_list |{@type:'d',label:0}在@this之后返回
=>[#“d”,:class=>“base”,:version=>3,:fieldTypes=>“first\u list=z”,:cluster=>132,:record=>2},
@attributes={:first_list=>[“#3:0”],:label=>“d”}>]
无论如何,对
@type
的查询失败了,但我的问题是关于嵌入式字段而不是链接,无论如何,我几乎看不出这个链接如何被视为我所问问题的答案,但我的问题是关于嵌入式字段而不是链接,无论如何,我几乎看不出这个链接如何被视为我所问问题的答案问