Looks like the best-order stuff is being covered just fine in the other
thread, nevermind :)

--
Matt Luongo
Co-Founder, Scholr.ly



On Fri, Aug 26, 2011 at 1:20 PM, Matt Luongo <[email protected]> wrote:

> Peter,
>
> The arbitrary Groovy is great, but if I understand correctly, there still
> isn't a straightforward way to do a best-first traversal *with* paging- is
> there? It seems like that would require being able to introduce some sort of
> server-side state through the GremlinPlugin (for pages). Maybe the solution
> would be to re-run the traversal each time, and then return different
> slices, but that's a pretty painful tradeoff.
>
> --
> Matt Luongo
> Co-Founder, Scholr.ly
>
>
>
> On Fri, Aug 26, 2011 at 1:12 PM, Matt Luongo <[email protected]> wrote:
>
>> You can run the script through the Python neo4jrestclient by using the
>> extension support.
>>
>> Try
>>     import neo4jrestclient.client as client
>>     gdb = client.GraphDatabase('http://localhost:7474/db/data')
>>     gdb.extensions.GremlinPlugin.execute_script(script="...")
>>
>> I think Javier is working on adding a "returns=<type>" style parameter in
>> the most recent source so that
>> the client can figure out what type to cast the data into-
>>
>>     import neo4jrestclient.constants as constants
>>     gdb.extensions.GremlinPlugin.execute_script(script="...",
>> returns=constants.NODE)
>>
>> But I haven't gotten this working quite yet.
>>
>> --
>> Matt Luongo
>> Co-Founder, Scholr.ly
>>
>>
>>
>> On Fri, Aug 26, 2011 at 12:11 PM, Boris Kizelshteyn <[email protected]>wrote:
>>
>>> I didn't have luck running it through neo4jrest, but the following
>>> function
>>> does the trick for me:
>>>
>>> script = "g.v(0)"
>>>
>>> def RunGremlinScript(script):
>>>
>>>    content=[]
>>>
>>>    jout=[]
>>>
>>>    out={}
>>>
>>>    try:
>>>
>>>        h = Http()
>>>
>>>        response, content = h.request(GRAPHSERVER +
>>> "ext/GremlinPlugin/graphdb/execute_script",\
>>>                            "POST",\
>>>                            json.dumps(dict(script=script)), \
>>>                            headers={'Accept':'application/json',
>>> 'Content-type': 'application/json'})
>>>
>>>
>>>        jcontent = json.loads(content)
>>>
>>>        for x in jcontent:
>>>
>>>            if isinstance(x, dict):
>>>
>>>                for arr in x['data']:
>>>
>>>                    for e in range(len(arr)):
>>>
>>>                        out[str(x['columns'][e])] = arr[e]
>>>
>>>                    jout.append(dict(out))
>>>
>>>            else:
>>>
>>>                return jcontent
>>>
>>>    except:
>>>
>>>        print "Unexpected error running gremlin: ", sys.exc_info()[0]
>>>
>>>        print str(traceback.print_exc())
>>>
>>>        print jcontent
>>>
>>>        return [{}]
>>>
>>>    return jout
>>>
>>> On Fri, Aug 26, 2011 at 12:01 PM, Jacopo Farina <
>>> [email protected]>wrote:
>>>
>>> > Nice!
>>> > is there a way to run it easily from python with neo4jrestclient,
>>> avoiding
>>> > creating an http request manually ? In general, I wasn't able to
>>> understand
>>> > how to run a Gremlin script, or just a query, in python through the
>>> > restclient library.
>>> > Probably is a very simple business, but I started using it in Python
>>> just
>>> > yesterday.
>>> >
>>> > Cheers,
>>> > Jacopo
>>> >
>>> > 2011/8/25 Peter Neubauer <[email protected]>
>>> >
>>> > > Guys,
>>> > > with the custom sorting in Lucene and this thread coming up all the
>>> time,
>>> > I
>>> > > took the time to document the execution of arbitrary Groovy and thus,
>>> > Java
>>> > > calls through REST. In the example below, there are calls to Neo4j
>>> APIs,
>>> > > Gremlin stuff and custom sorting using Lucene classes, and return of
>>> a
>>> > > Neo4j
>>> > > search hit object.
>>> > >
>>> > > You can do all this in a Neo4j Server plugin, but if you need to,
>>> this is
>>> > > an
>>> > > example on how to do it with only REST.
>>> > >
>>> > >
>>> > >
>>> >
>>> http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html#rest-api-send-an-arbitrary-groovy-script---lucene-sorting
>>> > >
>>> > > Hope that helps for future reference!
>>> > >
>>> > > Cheers,
>>> > >
>>> > > /peter neubauer
>>> > >
>>> > > GTalk:      neubauer.peter
>>> > > Skype       peter.neubauer
>>> > > Phone       +46 704 106975
>>> > > LinkedIn   http://www.linkedin.com/in/neubauer
>>> > > Twitter      http://twitter.com/peterneubauer
>>> > >
>>> > > http://www.neo4j.org               - Your high performance graph
>>> > database.
>>> > > http://startupbootcamp.org/    - Ă–resund - Innovation happens HERE.
>>> > > http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing
>>> party.
>>> > >
>>> > >
>>> > > On Thu, Aug 25, 2011 at 1:00 AM, Matt Luongo <[email protected]> wrote:
>>> > >
>>> > > > +1, we could really use that. Client-side sorting sucks.
>>> > > >
>>> > > > --
>>> > > > Matt Luongo
>>> > > > Co-Founder, Scholr.ly
>>> > > >
>>> > > >
>>> > > >
>>> > > > On Wed, Aug 24, 2011 at 4:43 PM, Aseem Kishore <
>>> > [email protected]
>>> > > > >wrote:
>>> > > >
>>> > > > > I've just spent a bunch of time reading into how one can control
>>> the
>>> > > > > ordering of a traverse beyond simple "breadth first" or "depth
>>> > first".
>>> > > > More
>>> > > > > precisely, even when breadth first, how one can control *which*
>>> > > neighbors
>>> > > > > are traversed first.
>>> > > > >
>>> > > > > (It matters less in which order they're traversed vs. which order
>>> > > they're
>>> > > > > returned if you're returning all results, since you can just sort
>>> on
>>> > > the
>>> > > > > client. But it matters a lot if you want to use the paged
>>> traverser,
>>> > > > since
>>> > > > > you're then only returning the first results.)
>>> > > > >
>>> > > > > I've learned that this is doable from Java by writing your own
>>> > > > > BranchSelector implementation:
>>> > > > >
>>> > > > > http://components.neo4j.org/neo4j/1.4.1/apidocs/
>>> > > > >
>>> > > > > I've found the built-in implementations, e.g. the pre-order
>>> > > breadth-first
>>> > > > > and depth-first:
>>> > > > >
>>> > > > >
>>> > > > >
>>> > > >
>>> > >
>>> >
>>> https://github.com/neo4j/community/blob/master/kernel/src/main/java/org/neo4j/kernel/PreorderBreadthFirstSelector.java
>>> > > > >
>>> > > > >
>>> > > > >
>>> > > >
>>> > >
>>> >
>>> https://github.com/neo4j/community/blob/master/kernel/src/main/java/org/neo4j/kernel/PreorderDepthFirstSelector.java
>>> > > > >
>>> > > > > To achieve a custom "best first", Igor Dovgiy for example shared
>>> that
>>> > > he
>>> > > > > modeled his implementation of the breadth-first selector, except
>>> just
>>> > > > using
>>> > > > > a PriorityQueue instead of a regular Queue.
>>> > > > >
>>> > > > > My question is: is there any way to specify this sort of thing
>>> over
>>> > the
>>> > > > > REST
>>> > > > > API instead of having to write a plugin? If not, does that sound
>>> like
>>> > a
>>> > > > > reasonable feature request?
>>> > > > >
>>> > > > > I really just want something simple: nodes ordered by some
>>> > "timestamp"
>>> > > > > property. It's killing us that we can't do this today. We might
>>> just
>>> > > have
>>> > > > > to
>>> > > > > look into writing this as a plugin...
>>> > > > >
>>> > > > > Thanks!
>>> > > > >
>>> > > > > Aseem
>>> > > > > _______________________________________________
>>> > > > > Neo4j mailing list
>>> > > > > [email protected]
>>> > > > > https://lists.neo4j.org/mailman/listinfo/user
>>> > > > >
>>> > > > _______________________________________________
>>> > > > Neo4j mailing list
>>> > > > [email protected]
>>> > > > https://lists.neo4j.org/mailman/listinfo/user
>>> > > >
>>> > > _______________________________________________
>>> > > Neo4j mailing list
>>> > > [email protected]
>>> > > https://lists.neo4j.org/mailman/listinfo/user
>>> > >
>>> > _______________________________________________
>>> > Neo4j mailing list
>>> > [email protected]
>>> > https://lists.neo4j.org/mailman/listinfo/user
>>> >
>>> _______________________________________________
>>> Neo4j mailing list
>>> [email protected]
>>> https://lists.neo4j.org/mailman/listinfo/user
>>>
>>
>>
>
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to