Reputation: 4300
I'm trying the queries given here in java:
import static com.tinkerpop.blueprints.Compare
Graph g = GraphOfTheGodsFactory.create("gods")
g.query().has("age", GREATER_THAN, 1000).vertices().iterator().hasNext
But this seems to return false
although that the below one return true
but doesn't take benefits of the index:
new GremlinPipeline(g.getVertices()).has("age", GREATER_THAN, 1000).toList().size() > 0
Does the example 5 here works for someone ?
Here is a project I created to test: https://github.com/joan38/TestTitan This should print the names of Gods who has more than 1000 years old, but it doesn't.
I really fell that TinkerPop or Titan is not straight forward :( or maybe it's me.
Cheers
Upvotes: 0
Views: 315
Reputation: 10904
That's an ElasticSearch pitfall. The problem is that your code simply runs too fast. The default refresh interval of ES is 1 second. I'm not aware of any method to configure this interval when using embedded ES, so all you can do is: add a Thread.sleep(1000)
between the code to load the graph and the code to query the data.
Upvotes: 1
Reputation: 46216
Not sure why it is not returning true
for you. See my Titan Console session:
gremlin> g = GraphOfTheGodsFactory.create("gods")
==>titangraph[local:gods]
gremlin> g.query().has("age", GREATER_THAN, 1000).vertices().iterator().hasNext()
==>true
To go a step further:
gremlin> g.query().has("age", GREATER_THAN, 1000).vertices()
==>v[20]
==>v[4]
==>v[16]
==>v[32]
gremlin> g.query().has("age", GREATER_THAN, 1000).vertices()._().age
==>4500
==>10000
==>5000
==>4000
gremlin> g.query().has("age", GREATER_THAN, 1000).has('name','saturn').vertices()._().map
==>{name=saturn, type=titan, age=10000}
gremlin> new GremlinPipeline(g.getVertices()).has("age", GREATER_THAN, 1000).toList().size()
==>4
Perhaps try it out in the Titan Console and make sure that works for you as it did for me here.
Upvotes: 0