![](/img/trans.png)
[英]how to create edge between new vertex and existing vertex using Java API in Titan Graph database
[英]Find vertex/node using Titan or TinkPop Java api
我正在試驗Titan Graph數據庫。 我對Neo4j有一點經驗。 在Neo4j中,有一個非常方便的api用於查詢具有特定標簽和屬性值的頂點/節點。 在Neo4j中:
Node node = graph.findNode(label, propertyName, propertyValue);
當然,創建索引是為了加快此查找過程。
在Titan中,我使用
TitanGraphIndex personIdIndex = titanManagement.buildIndex("personId", Vertex.class).addKey(personId).indexOnly(personLabel).unique().buildCompositeIndex();
現在,我想使用personLabel和特定的personId查找/查詢頂點。 我該怎么做? 在Titan或TinkerPop中是否有等效的Java API可以做到這一點?
為了利用索引,在查詢中包括頂點標簽很重要:
g.V().has(label, propertyName, propertyValue)
對於沒有標簽約束的索引( indexOnly(label)
),以下查詢就足夠了:
g.V().has(propertyName, propertyValue)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.