Comments (10)
a way to dodge the problem is
// gremlin scala
val gs: ScalaGraph = TitanFactory.open(conf)
// using elastic search's geo search
val closests = g.query().has("coords", WITHIN, Geoshape.circle(43.7323099, 7.420435, 0.05)).vertices().iterator
for (elem <- closests) {
println(elem.getId)
val node = gs.v(elem.getId)
}
from gremlin-scala.
Sorry I don't have a working titan setup so I cannot actually test it right now, but have you tried something like this:
val gs: ScalaGraph = TitanFactory.open(conf)
val closests = gs.V.has("coords", WITHIN, Geoshape.circle(43.7323099, 7.420435, 0.05)).toList
That should return a List of vertices for which the constraint is true..
from gremlin-scala.
I would like to try but I'm using 2.3 and lack most of the features described in the test like toList.
Is there a repos with a current snapshot or should I build from source?
from gremlin-scala.
Sorry for the delay, I had a very busy time. I ran the below with Gremlin 2.3.0 and it works fine (just put it in a unit test or App or so):
val graph = TinkerGraphFactory.createTinkerGraph
println(graph.V.has("name", "marko").toList)
// prints: [v[1]]
The reason you don't have toList is because you don't use graph.V like me, but graph.query.
HTH?
from gremlin-scala.
for toList, yes I had a wrong dependency.
for the answer to the initial question, no:
scala> val res = g.query().has("coords", WITHIN, Geoshape.circle(43.737239900000006, 7.423498500000001, .05)).vertices().iterator
res: java.util.Iterator[com.tinkerpop.blueprints.Vertex] = com.google.common.collect.Iterators$7@2476704e
scala> val res2 = gs.query().has("coords", WITHIN, Geoshape.circle(43.737239900000006, 7.423498500000001, .05)).vertices().iterator
<console>:14: error: type mismatch;
found : com.thinkaurelius.titan.core.attribute.Geoshape
required: com.tinkerpop.blueprints.Query.Compare
val res2 = gs.query().has("coords", WITHIN, Geoshape.circle(43.737239900000006, 7.423498500000001, .05)).vertices().iterator
where:
// the titan graph
val g = TitanFactory.open(conf)
// gremlin-scala wrapper
val gs = new ScalaGraph(g)
from gremlin-scala.
right, I had a quick look at Geoshape the other day and didn't see how it's related to Compare. Turns out it's not. I'll add support for that in 2.4.1, but now I'm going to focus on the 2.4.0 release.
from gremlin-scala.
ok thanks and btw great job!!
from gremlin-scala.
I've just had a look at what you're trying to do there...
gs.query returns you a GraphQuery, which doesn't have a Scala wrapper (like ScalaGraph wraps Graph).
I.e. you are working directly with a standard blueprints GraphQuery and that will work just fine, given that you use the correct types. As the compiler tells you, you're trying to pass in a Geoshape, while it's expecting a Query.Compare object.
I haven't actually done that myself, but I believe you need to make sure your GraphQuery is an instance of TitanGraphQuery, which supports a "has(String key, Relation relation, Object condition)". Your WITHIN is a relation, right?
I guess this is more a titan related question, not so much Gremlin Scala?
from gremlin-scala.
TitanIndexTest.java in titan-test contains some example usage of WITHIN. Maybe that helps?
from gremlin-scala.
yes it's true, it is more a titan related problem. The solution is to use ScalaGraph as a wrapper and keep TitanGraph for this kind of query:
val g = TitanFactory.open(conf)
val gs = new ScalaGraph(g)
g.query().has("coords", WITHIN, Geoshape.circle(43.737239900000006, 7.423498500000001, .05)).vertices()
you can close the issue (I did not opened it myself)
thanks for your help
from gremlin-scala.
Related Issues (20)
- Error when updating a vertex HOT 1
- @id attribute of case class without Option HOT 6
- How to get both edge and vertex properties? HOT 4
- Bump gremlin-scala lib version to 3.4.0.x after TinkerPop version bump to 3.4.0. HOT 6
- toCC() key not found HOT 11
- Create vertex with Custom vertex id HOT 1
- Create vertices if not exists and add relation HOT 1
- Getting Side Effects Of Traversal HOT 4
- how to set up tinkerpop for scala HOT 1
- How to get node(s) and children with all properties as a map HOT 5
- Support for list types with cardinality HOT 4
- Scala 2.13 support HOT 4
- Annotations.labelOf is catastrophically slow HOT 4
- g.V(vertexID).headOption() returning null.
- With Sack not initialising properly. HOT 1
- Update gremlin-scala to TinkerPop 3.5.x HOT 2
- Support for scala 3.x HOT 1
- select for tuples have unused type parameter HOT 1
- Unable to build a traversal dynamically with labelled steps
- Tinkerpop 3.6.x support: mergeE / mergeV traversal semantics
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gremlin-scala.