![](/img/trans.png)
[英]How to get the last level vertices of a particular vertex where last level value is not known using gremlinPipeLine
[英]How to add edges between set of vertices which are populated by using like search using GremlinPipeLine in java
我想通過使用類似搜索來過濾兩組頂點,然后如果要添加屬性,例如,我想在這些頂點之間添加邊。 location
匹配。
步驟1:使用mgr做喜歡的搜索否以100開頭
第2步:使用mgr做喜歡的搜索否喜歡以200開頭
步驟3:如果屬性表示例如,則在步驟1和2生成的頂點之間添加邊。 location
的頂點A和頂點B的匹配。
我想知道如何使用gremlinPipeLine
在Java中執行此gremlinPipeLine
我不確定您是否真的需要復雜的Gremlin來做到這一點:
// using some groovy for simplicity note that this is graph query syntax
// and not a "pipeline". to convert to java, you will just need to iterate
// the result of vertices() into an ArrayList and convert the use of
// each{} to foreach or some other java construct
mgr100 = g.query().has("mgrNo",CONTAINS_PREFIX,"100").vertices().toList()
mgr200 = g.query().has("mgrNo",CONTAINS_PREFIX,"200").vertices().toList()
mgr100.each {
mgr200.findAll{x -> x.location == it.location}.each{x -> it.addEdge('near', x)}
}
注意在CONTAINS_PREFIX周圍使用了一些Titan特定的語法。 雖然您可能會嘗試以某種方式將此代碼轉換為Gremlin Pipeline,但我不確定它的可讀性會比這大得多。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.