本文介绍了如何将包包含在查询中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题是.

那里接受的答案建议使用:

The accepted answer there suggests to use:

MATCH
   (i:Interface {name:'Action'}  )<-[:IMPLEMENTS|EXTENDS*1..10]- (class),
   (abstractAction:Class {name:'AbstractAction'})
   where not (class)-->(abstractAction)
RETURN class

效果很好,并给出了符合该条件的类的列表.

That works nicely, and gives a list of classes matching that condition.

我唯一的问题是:接口Action的名称是(惊奇)含糊的.绝对的类名称com.whatever.foo.bar.Action将是.但是,当我更改查询以使用{name:'com.whatever.foo.bar.Action'}时,得到的结果为空.

The only problem I have: the name of that interface Action is (surprise) ambiguous. The absolute class name com.whatever.foo.bar.Action would be. But when I change the query to use {name:'com.whatever.foo.bar.Action'} I get an empty result.

然后我尝试了{package:'com.whatever.foo.bar' name:'Action'},但这不起作用:

I then tried {package:'com.whatever.foo.bar' name:'Action'}, but that doesn't work:

有没有一种方法可以将搜索结果减少到我真正关心的 操作界面?

Is there a way reduce the search result to that Action interface I really care about?

推荐答案

有一个fqn节点属性-完全限定名称.

There is a fqn node property - full qualified name.

因此正确的查询应为:

MATCH
   (i:Interface {fqn:'com.whatever.foo.bar.Action'}  )<-[:IMPLEMENTS|EXTENDS*1..10]- (class),
   (abstractAction:Class {fqn:'com.whatever.foo.bar.AbstractAction'})
   where not (class)-->(abstractAction)
RETURN class

此查询产生笛卡尔乘积,这意味着它的性能不是很高.

This query produces a cartesian produckt which means that it's not very performant.

下图显示了针对我的一个项目的查询的执行计划:

The following image shows the execution plan of that query for one of my projects:

此问题更详细地解决了该问题:

This questions deals with that problem in more detail: Why does neo4j warn: "This query builds a cartesian product between disconnected patterns"?

由于此查询仅用于分析目的,而不是针对生产系统执行,因此我将忽略该提示.

Since this query is just for analysis purposes and not executed against a production system, I would ignore that hint.

这篇关于如何将包包含在查询中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 20:46