我在我的OrientDB數據庫中的文檔(1.0.1版本),在很大程度上與這樣的結構:查詢嵌入列表OrientDB
{
"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')
我遇到了同樣的問題。您可以在問題中發佈更新並接受它。那正是我正在尋找的。 – 2014-11-05 15:08:04
@DavidLaberge:謝謝你的建議。這個問題太古老了,我坦率地沒有完全記住它的背景,所以我會對這個操作感到有些不安。至少根據OrientDB的文檔,我還有一種感覺,即我的初始方法應該起作用,所以鼓勵人們像上面那樣重新調整數據庫會是一種錯誤。 – Henrik 2014-11-05 18:12:25