JanusGraph / JanusGraph/janusgraph
Search count bug
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5.8k
- Forks
- 1.2k
- Avg merge
- 13h 53m
- Merged PRs (30d)
- 6
Description
From list - https://groups.google.com/d/msg/janusgraph-users/trKs-UdkLkw/-2JGlKlECQAJ
# Setup
```
graph = JanusGraphFactory.open('conf/janusgraph-cassandra-es.properties')
mgmt = graph.openManagement()
name = mgmt.makePropertyKey('name').dataType(String.class).cardinality(SINGLE).make()
fermtype = mgmt.makePropertyKey('ferma_type').dataType(String.class).cardinality(SINGLE).make()
mgmt.buildIndex("byNameMixed", Vertex.class).addKey(name, Mapping.TEXTSTRING.asParameter()).buildMixedIndex("search");
mgmt.buildIndex("byFermaType", Vertex.class).addKey(fermtype).buildCompositeIndex();
mgmt.commit()
g = graph.traversal()
for (i = 0; i < 15000; i++) {
g.addV().property("ferma_type", "com.acme.model.Person").iterate()
}
g.tx().commit()
```
# Actual:
First `count()` returns 15k results.
Another query is run.
Second `count()` returns only 4k results.
```
gremlin> g.V().has("ferma_type", "com.acme.model.Person").count()
==>15000
gremlin> g.V().has("ferma_type", "com.acme.model.Person").count().profile()
==>Traversal Metrics
Step Count Traversers Time (ms) % Dur
=============================================================================================================
JanusGraphStep([],[ferma_type.eq(com.acme.model... 15000 15000 14.430 85.52
\_condition=(ferma_type = com.acme.model.Person)
\_isFitted=true
\_query=multiKSQ[1]@2147483647
\_index=byFermaType
\_orders=[]
\_isOrdered=true
optimization 0.094
backend-query 0.000
\_query=byFermaType:multiKSQ[1]@2147483647
backend-query 0.000
\_query=byFermaType:multiKSQ[1]@2147483647
backend-query 0.000
\_query=byFermaType:multiKSQ[1]@2147483647
backend-query 15000 7.347
\_query=byFermaType:multiKSQ[1]@2147483647
CountGlobalStep 1 1 2.443 14.48
>TOTAL - - 16.874 -
gremlin> g.V().has("ferma_type", "com.acme.model.Person").count()
==>15000
gremlin> g.V().has("ferma_type", "com.acme.model.Person").has("name", "John Doe")
gremlin> g.V().has("ferma_type", "com.acme.model.Person").has("name", "John Doe").profile()
==>Traversal Metrics
Step Count Traversers Time (ms) % Dur
=============================================================================================================
JanusGraphStep([],[ferma_type.eq(com.acme.model... 0.562 100.00
\_condition=(ferma_type = com.acme.model.Person AND name = John Doe)
\_isFitted=true
\_query=[(name = John Doe)]:byNameMixed
\_index=byNameMixed
\_orders=[]
\_isOrdered=true
\_index_impl=search
optimization 0.179
>TOTAL - - 0.562 -
gremlin> g.V().has("ferma_type", "com.acme.model.Person").count()
==>4000
gremlin> g.V().has("ferma_type", "com.acme.model.Person").count().profile()
==>Traversal Metrics
Step Count Traversers Time (ms) % Dur
=============================================================================================================
JanusGraphStep([],[ferma_type.eq(com.acme.model... 4000 4000 3.352 86.66
\_condition=(ferma_type = com.acme.model.Person)
\_isFitted=true
\_query=multiKSQ[1]@2147483647
\_index=byFermaType
\_orders=[]
\_isOrdered=true
optimization 0.071
CountGlobalStep 1 1 0.516 13.34
>TOTAL - - 3.868 -
gremlin> g.V().has("ferma_type", "com.acme.model.Person").count()
==>4000
```
# Expected:
Second call to `g.V().has("ferma_type", "com.acme.model.Person").count()` should have consistently returned 15k results.
## Note
Calling `g.tx().commit()` resets whatever is going on here as subsequently calling`count()` will return the correct results.
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
Reproduce the issue using the provided JanusGraph Cassandra/Elasticsearch setup, index definitions, and Gremlin queries. Start by comparing the composite-index count before and after the mixed-index query, then trace the transaction or query-state behavior involved. Done means repeated count() calls consistently return 15,000 without requiring g.tx().commit().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cassandra, elasticsearch, java
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100