janusgraph icon indicating copy to clipboard operation
janusgraph copied to clipboard

Incorrect result for query that filters on unset property when an index is present

Open InverseIntegral opened this issue 3 years ago • 1 comments

  • Version: 0.6.2
  • Storage Backend: inmemory
  • Mixed Index Backend: lucene
  • Link to discussed bug: https://lists.lfaidata.foundation/g/janusgraph-users/topic/92645197#6578
  • Expected Behavior: I would expect the result to stay the same even when an index is present.
  • Current Behavior: The result is different when an index is present.
  • Steps to Reproduce:
PropertiesConfiguration conf = ConfigurationUtil.loadPropertiesConfig("conf/test.properties");
JanusGraph graph = JanusGraphFactory.open(conf);

GraphTraversalSource g = graph.traversal();
JanusGraphManagement m = graph.openManagement();

VertexLabel l = m.makeVertexLabel("L").make();
PropertyKey p = m.makePropertyKey("p").dataType(Short.class).make();
PropertyKey q = m.makePropertyKey("q").dataType(UUID.class).make();
m.buildIndex("someName", Vertex.class).addKey(p).addKey(q).indexOnly(l).buildMixedIndex("search");
m.commit();

g.addV("L").property("p", (short) 1).next();
g.tx().commit();

System.out.println(g.V().hasLabel("L").has("q").count().next()); // 0
System.out.println(g.V().hasLabel("L").has("q", not(eq(UUID.randomUUID()))).count().next()); // 1

With the following configuration:

gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=inmemory
index.search.backend=lucene
index.search.directory=data/searchindex
schema.default=none

According to Marc this bug also happens with Cassandra and Elasticsearch. Furthermore, the bug doesn't seem to be related to the UUID type of property q.

InverseIntegral avatar Aug 04 '22 13:08 InverseIntegral

A quick workaround would be:

g = graph.traversal().withoutStrategies(JanusGraphMixedIndexCountStrategy.class)

li-boxuan avatar Aug 09 '22 16:08 li-boxuan