代码之家  ›  专栏  ›  技术社区  ›  Abhishek Raj

在Titan/Janus中启用力索引时索引失败

  •  4
  • Abhishek Raj  · 技术社区  · 7 年前

    generate-modern.groovy
    我的小问题是

    “g.V()。有('name','marko')”;

    文件,该索引已应用于人员的name属性。 我后来做了以下几点

    属性true dynamodb.properties

    org.janusgraph.core.JanusGraphException: Could not find a suitable index to answer graph query and graph scans are disabled: [(name = marko)]:VERTEX
    

    上述异常是由以下StandardJanusGraphTx类的方法引发的

        @Override
        public Iterator<JanusGraphElement> execute(final GraphCentricQuery query, final JointIndexQuery indexQuery, final Object exeInfo, final QueryProfiler profiler) {
            Iterator<JanusGraphElement> iter;
            if (!indexQuery.isEmpty()) {
                List<QueryUtil.IndexCall<Object>> retrievals = new ArrayList<QueryUtil.IndexCall<Object>>();
                for (int i = 0; i < indexQuery.size(); i++) {
                    final JointIndexQuery.Subquery subquery = indexQuery.getQuery(i);
    
                    retrievals.add(new QueryUtil.IndexCall<Object>() {
                        @Override
                        public Collection<Object> call(int limit) {
                            final JointIndexQuery.Subquery adjustedQuery = subquery.updateLimit(limit);
                            try {
                                return indexCache.get(adjustedQuery, new Callable<List<Object>>() {
                                    @Override
                                    public List<Object> call() throws Exception {
                                        return QueryProfiler.profile(subquery.getProfiler(), adjustedQuery, q -> indexSerializer.query(q, txHandle));
                                    }
                                });
                            } catch (Exception e) {
                                throw new JanusGraphException("Could not call index", e.getCause());
                            }
                        }
                    });
                }
    
    
                List<Object> resultSet = QueryUtil.processIntersectingRetrievals(retrievals, indexQuery.getLimit());
                iter = com.google.common.collect.Iterators.transform(resultSet.iterator(), getConversionFunction(query.getResultType()));
            } else {
                if (config.hasForceIndexUsage()) throw new JanusGraphException("Could not find a suitable index to answer graph query and graph scans are disabled: " + query);
                log.warn("Query requires iterating over all vertices [{}]. For better performance, use indexes", query.getCondition());
    
                QueryProfiler sub = profiler.addNested("scan");
                sub.setAnnotation(QueryProfiler.QUERY_ANNOTATION,indexQuery);
                sub.setAnnotation(QueryProfiler.FULLSCAN_ANNOTATION,true);
                sub.setAnnotation(QueryProfiler.CONDITION_ANNOTATION,query.getResultType());
    
                switch (query.getResultType()) {
                    case VERTEX:
                        return (Iterator) getVertices().iterator();
    
                    case EDGE:
                        return (Iterator) getEdges().iterator();
    
                    case PROPERTY:
                        return new VertexCentricEdgeIterable(getInternalVertices(),RelationCategory.PROPERTY).iterator();
    
                    default:
                        throw new IllegalArgumentException("Unexpected type: " + query.getResultType());
                }
            }
    
            return iter;
        }
    
    };
    


    问题是为什么列表是空的?当我们在 generate-modern.groovy 从JUnit测试查询时。这可以很好地工作,这意味着当使用相同的文件将相同的数据预加载到gremlin服务器时,列表不是空的。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Jason Plurad    7 年前

    这个 personByName index definition 使用标签约束。

    def personByName = mgmt.buildIndex("personByName", Vertex.class).addKey(name).indexOnly(person).buildCompositeIndex()
    

    g.V().has('person', 'name', 'marko')
    

    您可以在JanusGraph文档中了解更多信息 http://docs.janusgraph.org/latest/indexes.html#_label_constraint