janusgraph
janusgraph copied to clipboard
Inconsistent result for query when whether to use JanusGraphMixedIndexCountStrategy
- Version: 0.6.0, 0.6.1, 0.6.2
- Storage Backend: hbase
- Mixed Index Backend: elasticsearch
- Expected Behavior: I would expect the result to stay the same even when whether use JanusGraphMixedIndexCountStrategy
- Current Behavior: The result is different when use JanusGraphMixedIndexCountStrategy or not
- Steps to Reproduce:
GraphTraversalSource g = graph.traversal();
JanusGraphManagement m = graph.openManagement();
VertexLabel person = m.makeVertexLabel("person").make();
PropertyKey sex = m.makePropertyKey("sex").dataType(String.class).make();
m.buildIndex("personIndex", Vertex.class).addKey(sex).indexOnly(person).buildMixedIndex("search");
m.commit();
g.addV("person").property("sex", "man").next();
g.addV("person").property("sex", "man").next();
g.addV("person").property("sex", "man").next();
g.addV("person").property("sex", "man").next();
g.addV("person").property("sex", "man").next();
g.addV("person").property("sex", "man").next();
g.addV("person").property("sex", "man").next();
g.addV("person").property("sex", "man").next();
g.addV("person").property("sex", "man").next();
g.tx().commit();
System.out.println(g.V().has('person','sex','man').limit(2).count().next()); // 10
g = graph.traversal().withoutStrategies(JanusGraphMixedIndexCountStrategy.class)
System.out.println(g.V().has('person','sex','man').limit(2).count().next()); // 2
The ultimate reason is when query.hasLimit() the /_search API should be used instead of the /_count API
Thank you @dh-cloud for reporting! I think we should fix it in JanusGraphMixedIndexCountStrategy. I.e. if we detect limit before count step then we should still execute count via search as usual but then return Math.min(countResult, limit). That's just something on top of my head but maybe there are different solutions to this