Lucene neo4j sort with boolean fields

Posted by Daniele on Stack Overflow See other posts from Stack Overflow or by Daniele
Published on 2012-08-28T11:59:13Z Indexed on 2012/08/28 15:38 UTC
Read the original article Hit count: 304

Filed under:
|
|
|

I have indexed some documents (nodes of neo4j) with a boolean property which not always is present. Eg. Node1

label : "label A"

Node2:

label : "label A" (note, same label of node1) special : true

The goal is to get Node2 higher than node 1 for query "label A".

Here the code:

Index<Node> fulltextLucene = graphDb.index().forNodes( "my-index" );
Sort sort = new Sort(new SortField[] {SortField.FIELD_SCORE,
                     new SortField("special", SortField.????, true) }); 
IndexHits<Node> results = fulltextLucene.query( "label", new QueryContext( "label A").sort(sort));

How can I accomplish that?

Thanks

© Stack Overflow or respective owner

Related posts about query

Related posts about sorting