简体   繁体   English

OrientDB使用子查询的结果搜索索引

[英]OrientDB use result of subquery to search index

I am using OrientDb 2.1-rc4 as a document database. 我正在使用OrientDb 2.1-rc4作为文档数据库。 I have a MyClass class that gets updated very frequently by a multithreded application. 我有一个MyClass类,该类经常被多用途应用程序更新。 To improve performance I removed the link from the State class to MyClass , and added a link and index from MyClass to State. 为了提高性能,我删除了从State类到MyClass的链接,并添加了从MyClassState.的链接和索引State. In order to get all instances of MyClass I need to get a list of State rids and then query the index. 为了获取MyClass所有实例,我需要获取State rids的列表,然后查询索引。 This query gets my State rids. 该查询使我摆脱了状态。

SELECT DISTINCT(roles.views.states.@rid) 
FROM #12:1

returns 退货

[["#14:0","#14:1"]]

This query finds the correct rids in the index. 该查询在索引中找到正确的摆脱。

SELECT FROM index:MyClass.state 
where key in [#14:0,#14:1] 

When I put the two queries together. 当我将两个查询放在一起时。

SELECT FROM index:MWorkUnit.state 
where key in (SELECT DISTINCT(roles.views.states.@rid) FROM #12:1) 

I get the following error. 我收到以下错误。

java.lang.ClassCastException: com.orientechnologies.orient.core.sql.query.OSQLSynchQuery cannot be cast to java.util.List java.lang.ClassCastException:com.orientechnologies.orient.core.sql.query.OSQLSynchQuery无法转换为java.util.List

How do I get OrientDB to treat my subquery as an rid list? 如何让OrientDB将子查询视为摆脱列表?

Edit: This query works when not using the index. 编辑:不使用索引时此查询有效。

SELECT FROM MWorkUnit 
where state IN (SELECT expand(roles.views.states).@rid FROM #12:1)

This seems a bug on query against indexes: sub queries are not correctly evaluated. 这似乎是针对索引查询的错误:子查询未正确评估。 Please could you open a new issue or that? 请您打开一个新的问题?

This workaround should work: 此解决方法应起作用:

SELECT FROM index:MWorkUnit.state 
LET $list = (SELECT DISTINCT(roles.views.states.@rid) FROM #12:1) 
where key in $list

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM