Orientdb Orient DB:带权重的建议查询

Orientdb Orient DB:带权重的建议查询,orientdb,Orientdb,在博客文章中,他们写了一个查询,以16:0的比例查找分级为5的用户的分级为5的电影 这是模特儿->分级->电影 create class Movie extends V create property Movie.title String create class Person extends V create property Person.id String create class Rated extends E create property Rated.rating int 这是原始

在博客文章中,他们写了一个查询,以16:0的比例查找分级为5的用户的分级为5的电影

这是模特儿->分级->电影

create class Movie extends V
create property Movie.title String
create class Person extends V
create property Person.id String
create class Rated extends E
create property Rated.rating int
这是原始的建议查询

select title, count(*) as conto
  from (select expand(rid.outE('rated')[rating = 5].in)
          from (
        select @rid as rid, id as id, count(*) as conto
        from (select expand(outE('rated')    
              [rating=5].in.inE('rated'[rating=5].out) from #16:0)
              where @rid <> #16:0 group by rid, id order by conto desc limit 10))
 where title not in (select out('rated').title from #16:0)
 group by title
 order by conto desc
我在寻找一种增加权重的方法:一个对我的电影评分为5到100的用户X比一个只对我的电影评分为50的用户Y的权重要大。 与Y相比,X评级的电影应该更具优势

此查询可以通过以下方式计算权重:按16:0返回其他用户对电影评分为5的时间:

select @rid as rid, count(*) as p from (
      select from (
        select expand(outE('rated')[rating=5].in.inE('rated').out
                 ) from #16:0
      ) where @rid <> #16:0
    ) group by @rid order by p desc
但是我不知道如何编写建议查询来使用它

我试过这个,但不管用

select @rid as rid, title, count(*) from (
  select expand(rid.outE('rated')[rating=5].in) from (
    select @rid as rid, count(*) as p from (
      select from (
        select expand(outE('rated')[rating=5].in.inE('rated').out
                 ) from #16:0
      ) where @rid <> #16:0
    )group by @rid order by p desc
  )
)
where @rid not in (select out('rated').@rid from #16:0) group by @rid

我找到了一个可以检索分级电影及其关联“权重”的查询:

select a.@rid as rid, weight from (
    select u.outE("rated")[rating=5].in as a, count(*) as weight from (
      select @rid as u from (
        select expand(outE('rated')[rating=5].in.inE('rated')[rating=5].out) from #13:0
      ) where @rid <> #13:0
    ) group by u
  ) 
unwind rid

我不确定这是最好的方法,也许有人有其他想法?

嗨,你有测试数据库要分享吗?或者你可以写下你的模式细节吗?Thanksok抱歉,刚看到开头的链接..你能用ETL导入电影数据集吗?我被困在这一点上,它无法识别导入中的自定义拆分函数
select rid, count(*) as c, sum(weight) as w from(the_query_above)
where rid not in (select out("rated").@rid from #13:0)
group by rid