问题基本上是在多层嵌入式ODocument中搜索。让我解释一下,
我有三个orientDB类 - Feedback,File和FileContent。
反馈ODocument具有对文件ODocument的嵌入式字段引用,而File具有对FileContent的嵌入式引用。
FileContent有一个字段'content',它基本上包含我要搜索的文件的文本。
使用案例:在反馈类上编写一个选择查询,以便它为我提供具有搜索关键字的所有反馈文档。
即,
如果我想在文件内容中搜索关键字“progress”,并获取具有此关键字的所有反馈,则sql将如下所示:
从反馈中选择*,其中任何()如'%progress%'
但是此查询不会搜索文件内容 任何帮助表示赞赏。
以下是实现当前状态的示例事件序列:
orientdb {db=mydb}> create class Feedback;
orientdb {db=mydb}> create class File;
orientdb {db=mydb}> create class FileContent;
orientdb {db=mydb}> insert into FileContent (a,b) values ('Lebron James','is the King.')
orientdb {db=mydb}> select from FileContent
----+-----+------------+------------
# |@RID |a |b
----+-----+------------+------------
0 |#29:0|Lebron James|is the King.
----+-----+------------+------------
orientdb {db=mydb}> insert into File (c,d) values (#29:0, 'Steph Curry too!');
orientdb {db=mydb}> select from File
----+-----+-----+----------------
# |@RID |c |d
----+-----+-----+----------------
0 |#27:0|#29:0|Steph Curry too!
----+-----+-----+----------------
orientdb {db=mydb}> insert into Feedback (e,f) values (#27:0, 'The MVP is here.');
orientdb {db=mydb}> select from Feedback
----+-----+-----+----------------
# |@RID |e |f
----+-----+-----+----------------
0 |#28:0|#27:0|The MVP is here.
----+-----+-----+----------------
orientdb {db=mydb}> select from File where any() like '%Lebron%';
----+-----+-----+----------------
# |@RID |c |d
----+-----+-----+----------------
0 |#27:0|#29:0|Steph Curry too!
----+-----+-----+----------------
1 item(s) found. Query executed in 0.001 sec(s).
orientdb {db=mydb}> select from Feedback where any() like '%Lebron%';
0 item(s) found. Query executed in 0.001 sec(s).
// I want the last query to return the Feedback row. Is it possible?
// Also, I am not declaring the property as embedded here because then I have to do {"@type":"d", ...}
答案 0 :(得分:0)
使用遍历语句..它将解决您的问题..但您无法获得反馈,因为您必须使用嵌入式..
List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("TRAVERSE * FROM File where any() like '%Lebron%'"));
if (result != null && result.size() > 0) {
for (int i = 0; i < result.size(); i++) {
System.out.println(result.get(i).field("rid"));
}
}
这将返回File和FileContent类...