[Neo4j] Fwd: Lucene Custom Sort in Neo4j

Mattias Persson mattias at neotechnology.com
Tue Nov 22 09:13:37 CET 2011


As a parameter to the index GET perhaps?

GET .../index/node/myindex?query=name:*&sort=GivenName&order=desc

2011/11/22 Peter Neubauer <peter.neubauer at neotechnology.com>

> I agree.
> Sending arbitrary Groovy is not what you want a database to execute. Do you
> see any good index - neutral way to expose this? It's even very relevant to
> Cypher...
>
> /peter
>
> Sent from my phone, please excuse typos and autocorrection.
> On Nov 22, 2011 4:46 AM, "Tatham Oddie" <tatham at oddie.com.au> wrote:
>
> >
> >
> > --
> > Tatham Oddie
> > Tiny keyboard = tiny message
> >
> > Begin forwarded message:
> >
> > From: Tatham Oddie <tatham.oddie at readify.onmicrosoft.com<mailto:
> > tatham.oddie at readify.onmicrosoft.com>>
> > Date: 22 November 2011 14:43:00 AEDT
> > To: "tatham at oddie.com.au<mailto:tatham at oddie.com.au>" <
> tatham at oddie.com.au
> > <mailto:tatham at oddie.com.au>>
> > Subject: FW: Lucene Custom Sort in Neo4j
> >
> >
> >
> > From: Tatham Oddie [mailto:tatham.oddie at readify.onmicrosoft.com]
> > Sent: Tuesday, 22 November 2011 2:42 PM
> > To: Romiko Derbynew; user at lists.neo4j.org<mailto:user at lists.neo4j.org>
> > Cc: mystory-developers at barnardos.org.au<mailto:
> > mystory-developers at barnardos.org.au>; Tatham Oddie
> > Subject: RE: Lucene Custom Sort in Neo4j
> >
> >
> >
> http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html#rest-api-send-an-arbitrary-groovy-script---lucene-sorting
> >
> > Send something like this via /ext/GremlinPlugin/graphdb/execute_script:
> >
> > import org.neo4j.graphdb.index.*
> > import org.neo4j.index.lucene.*
> > import org.apache.lucene.search.*
> > neo4j = g.getRawGraph()
> > idxManager = neo4j.index()
> > clientIndex = idxManager.forNodes('agency123-clients')
> > query = new QueryContext( 'FamilyName:Smith' ).sort( new Sort(new
> > SortField( 'GivenName',SortField.STRING, true ) ) )
> > results = clientIndex.query( query )
> >
> > Pros:
> >
> >
> > ·         It’ll work
> >
> > Cons:
> >
> >
> > ·         You’d might as well stop calling it the “REST” API
> >
> > ·         It’s fragile to changes in either the “REST” API or the Java
> API
> > – twice the chance of getting bitten
> >
> > ·         It requires us to string concatenate snippets of Java code
> > together within our C#
> >
> > If you go down this route, please bury it very very deep in Neo4jClient
> > and expose a nicer API signature on top. :)
> >
> >
> > -- Tatham
> >
> >
> > From: Romiko Derbynew [mailto:Romiko.Derbynew at readify.onmicrosoft.com
> > ]<mailto:[mailto:Romiko.Derbynew at readify.onmicrosoft.com]>
> > Sent: Tuesday, 22 November 2011 2:36 PM
> > To: user at lists.neo4j.org<mailto:user at lists.neo4j.org>
> > Cc: mystory-developers at barnardos.org.au<mailto:
> > mystory-developers at barnardos.org.au>; Tatham Oddie
> > Subject: Lucene Custom Sort in Neo4j
> >
> > Hi Guys,
> >
> > What is the easiest way for me to build a custom full text sort for
> lucene
> > in Neo4j, the thing is, we use the REST API to query the index, and I
> would
> > like to apply a custom sort
> >
> > e.g.
> >
> > I want to change sorting to:
> > Sort by Relevance (Booster) then by IndexKey1 then by indexKey2.
> >
> > Currently, we have the default sort via the query parser api, but it is
> > not powerful enough(
> > http://lucene.apache.org/java/3_1_0/queryparsersyntax.html).
> >
> > Any ideas, how we could do this, and still leverage the REST API for
> index
> > queries?
> >
> > Cheers
> > _______________________________________________
> > Neo4j mailing list
> > User at lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
> _______________________________________________
> Neo4j mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [mattias at neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com


More information about the User mailing list