JanusGraph / JanusGraph/janusgraph
Lucene index returns incorrect results with has(SCORE_FIELD, lt(0.01d))
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5.8k
- Forks
- 1.2k
- Avg merge
- 13h 53m
- Merged PRs (30d)
- 6
Description
Reported on [janusgraph-users](https://groups.google.com/d/msg/janusgraph-users/BW6aq14NSxg/ho85mhxhAQAJ) by Kirk T.
```
gremlin> GRAPH_DIR = "/tmp/tmp_main/graph";
==>/tmp/tmp_main/graph
gremlin> INDEX_DIR = "/tmp/tmp_main/index";
==>/tmp/tmp_main/index
gremlin> SCORE_FIELD = "myScore";
==>myScore
gremlin> SCORE_INDEX = "scoreIndex";
==>scoreIndex
gremlin> INDEX_BACKEND = "mySearch";
==>mySearch
gremlin> graph = JanusGraphFactory.build().
......1> set("storage.backend", "berkeleyje").
......2> set("storage.directory", GRAPH_DIR).
......3> set("index." + INDEX_BACKEND + ".backend", "lucene").
......4> set("index." + INDEX_BACKEND + ".directory", INDEX_DIR).
......5> open();
==>standardjanusgraph[berkeleyje:/tmp/tmp_main/graph]
gremlin> graph.tx().rollback();
==>null
gremlin> mgmt = graph.openManagement();
==>org.janusgraph.graphdb.database.management.ManagementSystem@5a8816cc
gremlin> scoreProp = mgmt.makePropertyKey(SCORE_FIELD).
......1> dataType(Double.class).
......2> cardinality(Cardinality.SINGLE).make();
==>myScore
gremlin> mgmt.buildIndex(SCORE_INDEX, Vertex.class).
......1> addKey(scoreProp).
......2> buildMixedIndex(INDEX_BACKEND);
==>scoreIndex
gremlin> mgmt.commit();
==>null
gremlin> graph.addVertex(SCORE_FIELD, 0d);
==>v[4192]
gremlin> graph.tx().commit();
==>null
gremlin> Thread.sleep(5*1000)
==>null
gremlin> g = graph.traversal();
==>graphtraversalsource[standardjanusgraph[berkeleyje:/tmp/tmp_main/graph], standard]
gremlin> g.V().has(SCORE_FIELD, P.gt(-1d)).toList(); // should return vertex
==>v[4192]
gremlin> g.V().has(SCORE_FIELD, P.lt(1d)).toList(); // should return vertex, but does not
gremlin> g.V().has(SCORE_FIELD, P.between(-1d, 1d)).toList(); // should return vertex, but does not
gremlin>
```
The final traversal strategy is:
```
Final Traversal [JanusGraphStep([],[myScore.lt(1.0)])]
```
The problem does not occur with Elasticsearch.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Gremlin reproduction with a Lucene mixed index and compare the lt and between traversals with the gt case. Trace the Lucene index path that handles numeric range predicates; done means the lt(1d) and between(-1d, 1d) traversals return the vertex, matching the Elasticsearch behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100