java - 查询 OrientDB 中的嵌入列表

标签 java orientdb

我的 OrientDB 数据库(版本 1.0.1)中有一个文档,其结构大致如下:

{
    "timestamp": "...",
    "duration": 665,
    "testcases": [
        {
            "testName": "test01",
            "type": "ignore",
            "filename": "tests/test1.js"
        },
        {
            "iterations": 1,
            "runningTime": 45,
            "testName": "test02",
            "type": "pass",
            "filename": "tests/test1.js"
        },
        ...
        {
            "testName": "test05",
            "type": "ignore",
            "filename": "tests/test1.js"
        }
    ]
}

我如何查询整个列表,例如。如果我想查找包含类型为“忽略”的测试用例的所有文档?

我尝试了以下查询

select from testresult where testcases['type'] = 'ignore'

但这会导致 NumberFormatException

select from testresult where testcases[0]['type'] = 'ignore'

有效,但显然只查看每个文档的第一个列表元素。

select from testresult where testcases contains(type = 'ignore')

不提供任何结果,但查询被接受为有效。

更新: 如果测试用例存储为单独的文档而不是嵌入列表,则以下查询按预期工作。

select from testresult where testcases contains (type = 'ignore')

最佳答案

我知道这是一个老问题,但我遇到了同样的问题,只是在这里偶然发现了一个答案: https://www.mail-archive.com/orient-database@googlegroups.com/msg00662.html

以下应该有效。它在我非常相似的用例中确实如此。

select from testresult where 'ignore' in testcases.type

关于java - 查询 OrientDB 中的嵌入列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11360957/

相关文章:

java - OrientDB - OrientDB 函数不使用 Java 执行

Java:控制台类

node.js - 当我未登录 google 云端硬盘时,使用 google 云端硬盘 api 打开 google 云端硬盘文件

linux - OrientDB 作为 Ubuntu 上的守护进程不会停止

distributed - OrientDB 嵌入式和分布式

python-3.x - Graph Factory 找不到 gremlin.graph 属性配置

java - JLabel 未居中

java - 如何将旧版本的垃圾收集器添加到新版本的 JRE

Java Mail 较大的 base64 图像在 Linux 中具有换行符,导致它们在 Apple Mail.app 等客户端中失败

java - java中,为什么未初始化的char可以,但String不行