【发布时间】:2015-09-07 20:47:58
【问题描述】:
问题基本上是在多级嵌入式 ODocument 中进行搜索。让我解释一下,
我有三个 orientDB 类——Feedback、File 和 FileContent。
Feedback ODocument 具有对 File ODocument 的嵌入式字段引用,而 File 具有对 FileContent 的嵌入式引用。
FileContent 有一个“内容”字段,它基本上包含我要搜索的文件的文本。
用例:在反馈类上编写一个选择查询,以便它为我提供所有具有搜索关键字的反馈 ODocument。
也就是说,
如果我想在文件内容中搜索关键字'progress',并获取所有包含此关键字的反馈,sql 将如下所示:
select * from Feedback where any() like '%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", ...}
【问题讨论】:
-
您能否提供一系列命令来实现您当前的状态?我的意思是,你是如何嵌入字段的。
-
@vitorenesduarte 我刚刚发布了这个例子。这与我使用 Document API 所做的很接近。
-
@vitorenesduarte 有帮助吗?
-
您没有嵌入记录。嵌入式文档不拥有记录 ID。我相信,如果你真正嵌入它们,你会实现你想要的
-
@vitorenesduarte 那么为什么在一级间接搜索(我的示例中的倒数第二个查询)有效?