索引建立良好;
这里没有例外,并且graphManagement提交的很好;
graphManagement.buildIndex("uidIndex", Vertex.class).
addKey(graphManagement.getPropertyKey("uid_code")).
buildCompositeIndex();
我已经配置了 query.force-index = true ;;
但是当我尝试使用propertyKey'uid_code'添加一些顶点时,
代码如下:
Vertex vertex = g.V().addV(label).
property(propertyKey, propertyValue).
next();
抛出异常:
org.janusgraph.core.JanusGraphException: Could not find a suitable index to answer graph query and graph scans are disabled: [()]:VERTEX
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx$6.execute(StandardJanusGraphTx.java:1283)
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx$6.execute(StandardJanusGraphTx.java:1150)
at org.janusgraph.graphdb.query.QueryProcessor$LimitAdjustingIterator.getNewIterator(QueryProcessor.java:209)
at org.janusgraph.graphdb.query.LimitAdjustingIterator.hasNext(LimitAdjustingIterator.java:68)
at com.google.common.collect.Iterators$7.computeNext(Iterators.java:650)
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
at org.janusgraph.graphdb.query.ResultSetIterator.nextInternal(ResultSetIterator.java:54)
at org.janusgraph.graphdb.query.ResultSetIterator.<init>(ResultSetIterator.java:44)
at org.janusgraph.graphdb.query.QueryProcessor.iterator(QueryProcessor.java:68)
at com.google.common.collect.Iterables$7.iterator(Iterables.java:613)
at org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphStep.lambda$new$0(JanusGraphStep.java:71)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep.processNextStart(GraphStep.java:142)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:50)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep.processNextStart(MapStep.java:36)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:128)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:38)
at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.next(DefaultTraversal.java:200)
at dataTrans.KfkMsgParser.createMerge(KfkMsgParser.java:742)
有人可以告诉我是否忘记了文档中的内容吗?
或
我该如何解决这个问题?
答案 0 :(得分:2)
应该启用您的索引。
System.currTimeMilis()
您可以在此处检查索引生命周期:https://github.com/JanusGraph/janusgraph/wiki/Indexing
答案 1 :(得分:2)
要添加单个顶点,应直接在遍历源addV()
上调用g
:
String propertyKey = "uid_code";
Vertex vertex = g.addV(label).
property(propertyKey, propertyValue).
next();
当您使用g.V().addV(label)...
开始查询时,遍历会尝试使用g.V()
扫描所有顶点,从而引发异常。