Giter VIP home page Giter VIP logo

Comments (10)

vallettea avatar vallettea commented on August 31, 2024

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.

mpollmeier avatar mpollmeier commented on August 31, 2024

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.

vallettea avatar vallettea commented on August 31, 2024

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.

mpollmeier avatar mpollmeier commented on August 31, 2024

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.

vallettea avatar vallettea commented on August 31, 2024

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.

mpollmeier avatar mpollmeier commented on August 31, 2024

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.

vallettea avatar vallettea commented on August 31, 2024

ok thanks and btw great job!!

from gremlin-scala.

mpollmeier avatar mpollmeier commented on August 31, 2024

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.

mpollmeier avatar mpollmeier commented on August 31, 2024

TitanIndexTest.java in titan-test contains some example usage of WITHIN. Maybe that helps?

https://github.com/thinkaurelius/titan/blob/02e3f571f772577c309f65cb8e9446f232793dae/titan-test/src/main/java/com/thinkaurelius/titan/graphdb/TitanIndexTest.java

from gremlin-scala.

vallettea avatar vallettea commented on August 31, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.