Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
Thanks a lot ! On Tue, Sep 28, 2010 at 11:22 PM, Mattias Persson wrote: > I think there's a working version of it now... look at the tests for more > information: > https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java(testSorting, > testNumericValues). > 2010/9/24 Mattias Persson > >> >> >> 2010/9/24 Andreas Ronge >> >> On Thu, Sep 23, 2010 at 7:50 PM, Mattias Persson >>> wrote: >>> > 2010/9/23 Andreas Ronge >>> > >>> >> That's really good news ! >>> >> Does it also work if it was not indexes as Strings ? ( so that we can >>> >> sort integers or floats without any padding) >>> >> I guess that requires that neo4j-lucene adds NumericField instances to >>> >> the lucene document. >>> >> >>> > >>> > Exactly, I'm just working on a solution for that... I'm not sure it >>> should >>> > index all Integer, Long, Float, Double values implicitly as NumericField >>> > since those aren't searchable with a regular term query. Maybe do >>> something >>> > explicit like: >>> > >>> > myIndex.add( entity, "age", new ValueContext( 31 ).indexNumeric() ); >>> > ... >>> > // Query integer range >>> > myIndex.query( NumericRangeQuery.newIntRange( "age", 30, 40, true, >>> false >>> > ) ); >>> > // And with sorting (quite verbose though) >>> > myIndex.query( new QueryContext( NumericRangeQuery.newIntRange( >>> > "age", 0, 100, true, true ) ).sort( new Sort( new SortField( >>> "age", >>> > SortField.INT ) ) ) ); >>> > >>> > So that you must know what you're doing... would that be ok or any other >>> > better idea? >>> >>> I think it's great that we have access to the full lucene API in the >>> QueryContext. >>> I don't care if it's verbose since I will wrap it in a nice JRuby API :-) >>> I've already started to document how my lucene sorting and range query >>> API will look like in Neo4j.rb; >>> http://github.com/andreasronge/neo4j/wiki/Lucene >>> (I will specify both the field will be indexed as numerical and of what >>> type.) >>> >> >> Great, so I'll try to get this going and make a commit when I get the time >> (almost working locally). >> >> >> -- >> Mattias Persson, [matt...@neotechnology.com] >> Hacker, Neo Technology >> www.neotechnology.com >> > > > > -- > Mattias Persson, [matt...@neotechnology.com] > Hacker, Neo Technology > www.neotechnology.com > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
I think there's a working version of it now... look at the tests for more information: https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java(testSorting, testNumericValues). 2010/9/24 Mattias Persson > > > 2010/9/24 Andreas Ronge > > On Thu, Sep 23, 2010 at 7:50 PM, Mattias Persson >> wrote: >> > 2010/9/23 Andreas Ronge >> > >> >> That's really good news ! >> >> Does it also work if it was not indexes as Strings ? ( so that we can >> >> sort integers or floats without any padding) >> >> I guess that requires that neo4j-lucene adds NumericField instances to >> >> the lucene document. >> >> >> > >> > Exactly, I'm just working on a solution for that... I'm not sure it >> should >> > index all Integer, Long, Float, Double values implicitly as NumericField >> > since those aren't searchable with a regular term query. Maybe do >> something >> > explicit like: >> > >> >myIndex.add( entity, "age", new ValueContext( 31 ).indexNumeric() ); >> >... >> >// Query integer range >> >myIndex.query( NumericRangeQuery.newIntRange( "age", 30, 40, true, >> false >> > ) ); >> >// And with sorting (quite verbose though) >> >myIndex.query( new QueryContext( NumericRangeQuery.newIntRange( >> >"age", 0, 100, true, true ) ).sort( new Sort( new SortField( >> "age", >> > SortField.INT ) ) ) ); >> > >> > So that you must know what you're doing... would that be ok or any other >> > better idea? >> >> I think it's great that we have access to the full lucene API in the >> QueryContext. >> I don't care if it's verbose since I will wrap it in a nice JRuby API :-) >> I've already started to document how my lucene sorting and range query >> API will look like in Neo4j.rb; >> http://github.com/andreasronge/neo4j/wiki/Lucene >> (I will specify both the field will be indexed as numerical and of what >> type.) >> > > Great, so I'll try to get this going and make a commit when I get the time > (almost working locally). > > > -- > Mattias Persson, [matt...@neotechnology.com] > Hacker, Neo Technology > www.neotechnology.com > -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
2010/9/24 Andreas Ronge > On Thu, Sep 23, 2010 at 7:50 PM, Mattias Persson > wrote: > > 2010/9/23 Andreas Ronge > > > >> That's really good news ! > >> Does it also work if it was not indexes as Strings ? ( so that we can > >> sort integers or floats without any padding) > >> I guess that requires that neo4j-lucene adds NumericField instances to > >> the lucene document. > >> > > > > Exactly, I'm just working on a solution for that... I'm not sure it > should > > index all Integer, Long, Float, Double values implicitly as NumericField > > since those aren't searchable with a regular term query. Maybe do > something > > explicit like: > > > >myIndex.add( entity, "age", new ValueContext( 31 ).indexNumeric() ); > >... > >// Query integer range > >myIndex.query( NumericRangeQuery.newIntRange( "age", 30, 40, true, > false > > ) ); > >// And with sorting (quite verbose though) > >myIndex.query( new QueryContext( NumericRangeQuery.newIntRange( > >"age", 0, 100, true, true ) ).sort( new Sort( new SortField( > "age", > > SortField.INT ) ) ) ); > > > > So that you must know what you're doing... would that be ok or any other > > better idea? > > I think it's great that we have access to the full lucene API in the > QueryContext. > I don't care if it's verbose since I will wrap it in a nice JRuby API :-) > I've already started to document how my lucene sorting and range query > API will look like in Neo4j.rb; > http://github.com/andreasronge/neo4j/wiki/Lucene > (I will specify both the field will be indexed as numerical and of what > type.) > Great, so I'll try to get this going and make a commit when I get the time (almost working locally). -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
On Thu, Sep 23, 2010 at 7:50 PM, Mattias Persson wrote: > 2010/9/23 Andreas Ronge > >> That's really good news ! >> Does it also work if it was not indexes as Strings ? ( so that we can >> sort integers or floats without any padding) >> I guess that requires that neo4j-lucene adds NumericField instances to >> the lucene document. >> > > Exactly, I'm just working on a solution for that... I'm not sure it should > index all Integer, Long, Float, Double values implicitly as NumericField > since those aren't searchable with a regular term query. Maybe do something > explicit like: > > myIndex.add( entity, "age", new ValueContext( 31 ).indexNumeric() ); > ... > // Query integer range > myIndex.query( NumericRangeQuery.newIntRange( "age", 30, 40, true, false > ) ); > // And with sorting (quite verbose though) > myIndex.query( new QueryContext( NumericRangeQuery.newIntRange( > "age", 0, 100, true, true ) ).sort( new Sort( new SortField( "age", > SortField.INT ) ) ) ); > > So that you must know what you're doing... would that be ok or any other > better idea? I think it's great that we have access to the full lucene API in the QueryContext. I don't care if it's verbose since I will wrap it in a nice JRuby API :-) I've already started to document how my lucene sorting and range query API will look like in Neo4j.rb; http://github.com/andreasronge/neo4j/wiki/Lucene (I will specify both the field will be indexed as numerical and of what type.) /Andreas > > >> /Andreas >> >> >> >> On Thu, Sep 23, 2010 at 11:21 AM, Mattias Persson >> wrote: >> > 2010/9/23 Mattias Persson >> > >> >> Btw I don't think lucene can do that kind of multiple-field sorting for >> >> you, or can it? >> >> >> > >> > Scratch that... you can do: >> > >> > myNodeIndex.query( new QueryContext( "name:*...@gmail.com" ).sort( new >> Sort( >> > new SortField( "name", SortField.STRING ) ) ); >> > >> > that way you let Lucence sort the result for you on the key "name". >> > >> > >> >> >> >> 2010/9/23 Mattias Persson >> >> >> >> It doesn't try to use NumericField... maybe that can be done somehow so >> >>> that range queries can more easily be asked, I'll add that as a ticket >> >>> >> >>> 2010/9/23 Paddy >> >>> >> >>> Hi Andreas, >> Yes it looks like you don't need to wrap it in a padded string. >> I tried using myIndex.add(ndOne, "time",1f); it will stills work. >> thanks >> Paddy >> >> On Thu, Sep 23, 2010 at 12:37 AM, Andreas Ronge < >> andreas.ro...@jayway.se >> >wrote: >> >> > Hi Paddy >> > >> > Thanks for the response. >> > But it would be nice to avoid wrapping integer or float values in >> > padded strings, as you described in your example: >> > > Node ndOne = gds.createNode(); >> > > ndOne.setProperty("time", "1.3"); >> > > myIndex.add(ndOne, "time", ndOne.getProperty("time") ); >> > Instead I believe it's possible in Lucene 3.0 to index the time >> > property as a float. The question is if this feature is exposed in >> the >> > Neo4j Lucene API ? >> > >> > Cheers >> > Andreas >> > >> > >> > On Thu, Sep 23, 2010 at 8:43 AM, Paddy wrote: >> > > Hi Andres, >> > > Not sure about the use of sorting but I have previously tried some >> > numeric >> > > range queries with the new indexProvider. >> > > I've added my some test code i used below. >> > > >> > > >> > > Cheers >> > > Paddy >> > > >> > > public class indexTest { >> > > static GraphDatabaseService gds; >> > > static IndexProvider provider; >> > > >> > > @BeforeClass >> > > public static void setup() { >> > > gds = new EmbeddedGraphDatabase("data/neodb/neodb-tmp"); >> > > provider = new LuceneIndexProvider( gds ); >> > > } >> > > >> > > @Test >> > > public void fullTextIndex() { >> > > Transaction tx = gds.beginTx(); >> > > try { >> > > Node ndOne = gds.createNode(); >> > > ndOne.setProperty("time", "1.3"); >> > > Node ndTwo = gds.createNode(); >> > > ndTwo.setProperty("time", "1.5"); >> > > Node ndThree = gds.createNode(); >> > > ndThree.setProperty("time", "2.0"); >> > > Node ndFour = gds.createNode(); >> > > ndFour.setProperty("time", "3.0"); >> > > Node ndFive = gds.createNode(); >> > > ndFive.setProperty("time", "5.0"); >> > > >> > > Index myIndex = provider.nodeIndex( "fulltext", >> > > LuceneIndexProvider.FULLTEXT_CONFIG ); >> > > myIndex.add(ndOne, "time", ndOne.getProperty("time") ); >> > > myIndex.add(ndTwo, "time", ndTwo.getProperty("time") ); >> > > myIndex.add(ndThree,"time", ndThree.getProperty("time") ); >> > > myIndex.add(ndFour, "time", ndFour.getProperty("time") ); >> > > myIndex.add(ndFive, "time", ndFive.getProperty("time") ); >> > > >> > > for ( Node searchHit : myIndex.quer
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
2010/9/23 Andreas Ronge > That's really good news ! > Does it also work if it was not indexes as Strings ? ( so that we can > sort integers or floats without any padding) > I guess that requires that neo4j-lucene adds NumericField instances to > the lucene document. > Exactly, I'm just working on a solution for that... I'm not sure it should index all Integer, Long, Float, Double values implicitly as NumericField since those aren't searchable with a regular term query. Maybe do something explicit like: myIndex.add( entity, "age", new ValueContext( 31 ).indexNumeric() ); ... // Query integer range myIndex.query( NumericRangeQuery.newIntRange( "age", 30, 40, true, false ) ); // And with sorting (quite verbose though) myIndex.query( new QueryContext( NumericRangeQuery.newIntRange( "age", 0, 100, true, true ) ).sort( new Sort( new SortField( "age", SortField.INT ) ) ) ); So that you must know what you're doing... would that be ok or any other better idea? > /Andreas > > > > On Thu, Sep 23, 2010 at 11:21 AM, Mattias Persson > wrote: > > 2010/9/23 Mattias Persson > > > >> Btw I don't think lucene can do that kind of multiple-field sorting for > >> you, or can it? > >> > > > > Scratch that... you can do: > > > > myNodeIndex.query( new QueryContext( "name:*...@gmail.com" ).sort( new > Sort( > > new SortField( "name", SortField.STRING ) ) ); > > > > that way you let Lucence sort the result for you on the key "name". > > > > > >> > >> 2010/9/23 Mattias Persson > >> > >> It doesn't try to use NumericField... maybe that can be done somehow so > >>> that range queries can more easily be asked, I'll add that as a ticket > >>> > >>> 2010/9/23 Paddy > >>> > >>> Hi Andreas, > Yes it looks like you don't need to wrap it in a padded string. > I tried using myIndex.add(ndOne, "time",1f); it will stills work. > thanks > Paddy > > On Thu, Sep 23, 2010 at 12:37 AM, Andreas Ronge < > andreas.ro...@jayway.se > >wrote: > > > Hi Paddy > > > > Thanks for the response. > > But it would be nice to avoid wrapping integer or float values in > > padded strings, as you described in your example: > > > Node ndOne = gds.createNode(); > > > ndOne.setProperty("time", "1.3"); > > >myIndex.add(ndOne, "time", ndOne.getProperty("time") ); > > Instead I believe it's possible in Lucene 3.0 to index the time > > property as a float. The question is if this feature is exposed in > the > > Neo4j Lucene API ? > > > > Cheers > > Andreas > > > > > > On Thu, Sep 23, 2010 at 8:43 AM, Paddy wrote: > > > Hi Andres, > > > Not sure about the use of sorting but I have previously tried some > > numeric > > > range queries with the new indexProvider. > > > I've added my some test code i used below. > > > > > > > > > Cheers > > > Paddy > > > > > > public class indexTest { > > > static GraphDatabaseService gds; > > > static IndexProvider provider; > > > > > > @BeforeClass > > > public static void setup() { > > > gds = new EmbeddedGraphDatabase("data/neodb/neodb-tmp"); > > >provider = new LuceneIndexProvider( gds ); > > > } > > > > > > @Test > > > public void fullTextIndex() { > > > Transaction tx = gds.beginTx(); > > > try { > > > Node ndOne = gds.createNode(); > > > ndOne.setProperty("time", "1.3"); > > > Node ndTwo = gds.createNode(); > > > ndTwo.setProperty("time", "1.5"); > > > Node ndThree = gds.createNode(); > > > ndThree.setProperty("time", "2.0"); > > > Node ndFour = gds.createNode(); > > > ndFour.setProperty("time", "3.0"); > > > Node ndFive = gds.createNode(); > > > ndFive.setProperty("time", "5.0"); > > > > > >Index myIndex = provider.nodeIndex( "fulltext", > > > LuceneIndexProvider.FULLTEXT_CONFIG ); > > >myIndex.add(ndOne, "time", ndOne.getProperty("time") ); > > >myIndex.add(ndTwo, "time", ndTwo.getProperty("time") ); > > >myIndex.add(ndThree,"time", ndThree.getProperty("time") ); > > >myIndex.add(ndFour, "time", ndFour.getProperty("time") ); > > >myIndex.add(ndFive, "time", ndFive.getProperty("time") ); > > > > > >for ( Node searchHit : myIndex.query( "time:[1.5 TO 4.3]" ) ) > > >{ > > > System.out.println( "Found " + searchHit.toString() ); > > > System.out.println("time" + > searchHit.getProperty("time")); > > > } > > > > > > tx.success(); > > > } finally { > > > tx.finish(); > > > } > > > } > > > } > > > > > > On Wed, Sep 22, 2010 at 11:15 PM, Andreas Ronge < > andreas.ro...@jayway.se > > >wrote: > > > > > >> Hi > > >> > > >> In the example > > >> > > > > https://svn.neo4j.org/laboratory/components
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
That's really good news ! Does it also work if it was not indexes as Strings ? ( so that we can sort integers or floats without any padding) I guess that requires that neo4j-lucene adds NumericField instances to the lucene document. /Andreas On Thu, Sep 23, 2010 at 11:21 AM, Mattias Persson wrote: > 2010/9/23 Mattias Persson > >> Btw I don't think lucene can do that kind of multiple-field sorting for >> you, or can it? >> > > Scratch that... you can do: > > myNodeIndex.query( new QueryContext( "name:*...@gmail.com" ).sort( new Sort( > new SortField( "name", SortField.STRING ) ) ); > > that way you let Lucence sort the result for you on the key "name". > > >> >> 2010/9/23 Mattias Persson >> >> It doesn't try to use NumericField... maybe that can be done somehow so >>> that range queries can more easily be asked, I'll add that as a ticket >>> >>> 2010/9/23 Paddy >>> >>> Hi Andreas, Yes it looks like you don't need to wrap it in a padded string. I tried using myIndex.add(ndOne, "time",1f); it will stills work. thanks Paddy On Thu, Sep 23, 2010 at 12:37 AM, Andreas Ronge >>> >wrote: > Hi Paddy > > Thanks for the response. > But it would be nice to avoid wrapping integer or float values in > padded strings, as you described in your example: > > Node ndOne = gds.createNode(); > > ndOne.setProperty("time", "1.3"); > > myIndex.add(ndOne, "time", ndOne.getProperty("time") ); > Instead I believe it's possible in Lucene 3.0 to index the time > property as a float. The question is if this feature is exposed in the > Neo4j Lucene API ? > > Cheers > Andreas > > > On Thu, Sep 23, 2010 at 8:43 AM, Paddy wrote: > > Hi Andres, > > Not sure about the use of sorting but I have previously tried some > numeric > > range queries with the new indexProvider. > > I've added my some test code i used below. > > > > > > Cheers > > Paddy > > > > public class indexTest { > > static GraphDatabaseService gds; > > static IndexProvider provider; > > > > @BeforeClass > > public static void setup() { > > gds = new EmbeddedGraphDatabase("data/neodb/neodb-tmp"); > > provider = new LuceneIndexProvider( gds ); > > } > > > > @Test > > public void fullTextIndex() { > > Transaction tx = gds.beginTx(); > > try { > > Node ndOne = gds.createNode(); > > ndOne.setProperty("time", "1.3"); > > Node ndTwo = gds.createNode(); > > ndTwo.setProperty("time", "1.5"); > > Node ndThree = gds.createNode(); > > ndThree.setProperty("time", "2.0"); > > Node ndFour = gds.createNode(); > > ndFour.setProperty("time", "3.0"); > > Node ndFive = gds.createNode(); > > ndFive.setProperty("time", "5.0"); > > > > Index myIndex = provider.nodeIndex( "fulltext", > > LuceneIndexProvider.FULLTEXT_CONFIG ); > > myIndex.add(ndOne, "time", ndOne.getProperty("time") ); > > myIndex.add(ndTwo, "time", ndTwo.getProperty("time") ); > > myIndex.add(ndThree,"time", ndThree.getProperty("time") ); > > myIndex.add(ndFour, "time", ndFour.getProperty("time") ); > > myIndex.add(ndFive, "time", ndFive.getProperty("time") ); > > > > for ( Node searchHit : myIndex.query( "time:[1.5 TO 4.3]" ) ) > > { > > System.out.println( "Found " + searchHit.toString() ); > > System.out.println("time" + searchHit.getProperty("time")); > > } > > > > tx.success(); > > } finally { > > tx.finish(); > > } > > } > > } > > > > On Wed, Sep 22, 2010 at 11:15 PM, Andreas Ronge < andreas.ro...@jayway.se > >wrote: > > > >> Hi > >> > >> In the example > >> > https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java > >> I only see how to sort by Sort.RELEVANCE and Sort.INDEXORDER. > >> How do I sort ascending/ on different fields ? > >> > >> Another related question, how does neo4j work with the new improved > >> numerical capabilities of lucene 3.0. > >> Example if I add an integer with > >> org.neo4j.graphdb.index.Index.add(entity, key, integer_value) will it > >> be index as a NumericField so that I (how?) can use > >> NumericRangeQueries ? > >> > >> (In old lucene one had to convert integers to strings and pad it with > >> zeros) > >> > >> Cheers > >> Andres > >> ___ > >> Neo4j mailing list > >> User@lists.neo4j.org > >> https://lists.neo4j.org/mailman/listinfo/user > >> > > ___ > > Neo4j mailing list > > User@lists.neo4j.org > > https://lis
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
2010/9/23 Mattias Persson > Btw I don't think lucene can do that kind of multiple-field sorting for > you, or can it? > Scratch that... you can do: myNodeIndex.query( new QueryContext( "name:*...@gmail.com" ).sort( new Sort( new SortField( "name", SortField.STRING ) ) ); that way you let Lucence sort the result for you on the key "name". > > 2010/9/23 Mattias Persson > > It doesn't try to use NumericField... maybe that can be done somehow so >> that range queries can more easily be asked, I'll add that as a ticket >> >> 2010/9/23 Paddy >> >> Hi Andreas, >>> Yes it looks like you don't need to wrap it in a padded string. >>> I tried using myIndex.add(ndOne, "time",1f); it will stills work. >>> thanks >>> Paddy >>> >>> On Thu, Sep 23, 2010 at 12:37 AM, Andreas Ronge >> >wrote: >>> >>> > Hi Paddy >>> > >>> > Thanks for the response. >>> > But it would be nice to avoid wrapping integer or float values in >>> > padded strings, as you described in your example: >>> > > Node ndOne = gds.createNode(); >>> > > ndOne.setProperty("time", "1.3"); >>> > >myIndex.add(ndOne, "time", ndOne.getProperty("time") ); >>> > Instead I believe it's possible in Lucene 3.0 to index the time >>> > property as a float. The question is if this feature is exposed in the >>> > Neo4j Lucene API ? >>> > >>> > Cheers >>> > Andreas >>> > >>> > >>> > On Thu, Sep 23, 2010 at 8:43 AM, Paddy wrote: >>> > > Hi Andres, >>> > > Not sure about the use of sorting but I have previously tried some >>> > numeric >>> > > range queries with the new indexProvider. >>> > > I've added my some test code i used below. >>> > > >>> > > >>> > > Cheers >>> > > Paddy >>> > > >>> > > public class indexTest { >>> > > static GraphDatabaseService gds; >>> > > static IndexProvider provider; >>> > > >>> > > @BeforeClass >>> > > public static void setup() { >>> > > gds = new EmbeddedGraphDatabase("data/neodb/neodb-tmp"); >>> > >provider = new LuceneIndexProvider( gds ); >>> > > } >>> > > >>> > > @Test >>> > > public void fullTextIndex() { >>> > > Transaction tx = gds.beginTx(); >>> > > try { >>> > > Node ndOne = gds.createNode(); >>> > > ndOne.setProperty("time", "1.3"); >>> > > Node ndTwo = gds.createNode(); >>> > > ndTwo.setProperty("time", "1.5"); >>> > > Node ndThree = gds.createNode(); >>> > > ndThree.setProperty("time", "2.0"); >>> > > Node ndFour = gds.createNode(); >>> > > ndFour.setProperty("time", "3.0"); >>> > > Node ndFive = gds.createNode(); >>> > > ndFive.setProperty("time", "5.0"); >>> > > >>> > >Index myIndex = provider.nodeIndex( "fulltext", >>> > > LuceneIndexProvider.FULLTEXT_CONFIG ); >>> > >myIndex.add(ndOne, "time", ndOne.getProperty("time") ); >>> > >myIndex.add(ndTwo, "time", ndTwo.getProperty("time") ); >>> > >myIndex.add(ndThree,"time", ndThree.getProperty("time") ); >>> > >myIndex.add(ndFour, "time", ndFour.getProperty("time") ); >>> > >myIndex.add(ndFive, "time", ndFive.getProperty("time") ); >>> > > >>> > >for ( Node searchHit : myIndex.query( "time:[1.5 TO 4.3]" ) ) >>> > >{ >>> > > System.out.println( "Found " + searchHit.toString() ); >>> > > System.out.println("time" + searchHit.getProperty("time")); >>> > > } >>> > > >>> > > tx.success(); >>> > > } finally { >>> > > tx.finish(); >>> > > } >>> > > } >>> > > } >>> > > >>> > > On Wed, Sep 22, 2010 at 11:15 PM, Andreas Ronge < >>> andreas.ro...@jayway.se >>> > >wrote: >>> > > >>> > >> Hi >>> > >> >>> > >> In the example >>> > >> >>> > >>> https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java >>> > >> I only see how to sort by Sort.RELEVANCE and Sort.INDEXORDER. >>> > >> How do I sort ascending/ on different fields ? >>> > >> >>> > >> Another related question, how does neo4j work with the new improved >>> > >> numerical capabilities of lucene 3.0. >>> > >> Example if I add an integer with >>> > >> org.neo4j.graphdb.index.Index.add(entity, key, integer_value) will >>> it >>> > >> be index as a NumericField so that I (how?) can use >>> > >> NumericRangeQueries ? >>> > >> >>> > >> (In old lucene one had to convert integers to strings and pad it >>> with >>> > >> zeros) >>> > >> >>> > >> Cheers >>> > >> Andres >>> > >> ___ >>> > >> Neo4j mailing list >>> > >> User@lists.neo4j.org >>> > >> https://lists.neo4j.org/mailman/listinfo/user >>> > >> >>> > > ___ >>> > > Neo4j mailing list >>> > > User@lists.neo4j.org >>> > > https://lists.neo4j.org/mailman/listinfo/user >>> > > >>> > ___ >>> > Neo4j mailing list >>> > User@lists.neo4j.org >>> > https://lists.neo4j.org/mailman/listinfo/user >>> > >>> ___ >>> Neo4j mailing list >>> User@lists.neo4j.org >>> https://lists.neo4j.org/mailman/listinfo/user >>> >> >> >> >> -- >> Mattias Persson, [matt...@neotechnology.com] >> Hacker, Neo Technolog
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
Btw I don't think lucene can do that kind of multiple-field sorting for you, or can it? 2010/9/23 Mattias Persson > It doesn't try to use NumericField... maybe that can be done somehow so > that range queries can more easily be asked, I'll add that as a ticket > > 2010/9/23 Paddy > > Hi Andreas, >> Yes it looks like you don't need to wrap it in a padded string. >> I tried using myIndex.add(ndOne, "time",1f); it will stills work. >> thanks >> Paddy >> >> On Thu, Sep 23, 2010 at 12:37 AM, Andreas Ronge > >wrote: >> >> > Hi Paddy >> > >> > Thanks for the response. >> > But it would be nice to avoid wrapping integer or float values in >> > padded strings, as you described in your example: >> > > Node ndOne = gds.createNode(); >> > > ndOne.setProperty("time", "1.3"); >> > >myIndex.add(ndOne, "time", ndOne.getProperty("time") ); >> > Instead I believe it's possible in Lucene 3.0 to index the time >> > property as a float. The question is if this feature is exposed in the >> > Neo4j Lucene API ? >> > >> > Cheers >> > Andreas >> > >> > >> > On Thu, Sep 23, 2010 at 8:43 AM, Paddy wrote: >> > > Hi Andres, >> > > Not sure about the use of sorting but I have previously tried some >> > numeric >> > > range queries with the new indexProvider. >> > > I've added my some test code i used below. >> > > >> > > >> > > Cheers >> > > Paddy >> > > >> > > public class indexTest { >> > > static GraphDatabaseService gds; >> > > static IndexProvider provider; >> > > >> > > @BeforeClass >> > > public static void setup() { >> > > gds = new EmbeddedGraphDatabase("data/neodb/neodb-tmp"); >> > >provider = new LuceneIndexProvider( gds ); >> > > } >> > > >> > > @Test >> > > public void fullTextIndex() { >> > > Transaction tx = gds.beginTx(); >> > > try { >> > > Node ndOne = gds.createNode(); >> > > ndOne.setProperty("time", "1.3"); >> > > Node ndTwo = gds.createNode(); >> > > ndTwo.setProperty("time", "1.5"); >> > > Node ndThree = gds.createNode(); >> > > ndThree.setProperty("time", "2.0"); >> > > Node ndFour = gds.createNode(); >> > > ndFour.setProperty("time", "3.0"); >> > > Node ndFive = gds.createNode(); >> > > ndFive.setProperty("time", "5.0"); >> > > >> > >Index myIndex = provider.nodeIndex( "fulltext", >> > > LuceneIndexProvider.FULLTEXT_CONFIG ); >> > >myIndex.add(ndOne, "time", ndOne.getProperty("time") ); >> > >myIndex.add(ndTwo, "time", ndTwo.getProperty("time") ); >> > >myIndex.add(ndThree,"time", ndThree.getProperty("time") ); >> > >myIndex.add(ndFour, "time", ndFour.getProperty("time") ); >> > >myIndex.add(ndFive, "time", ndFive.getProperty("time") ); >> > > >> > >for ( Node searchHit : myIndex.query( "time:[1.5 TO 4.3]" ) ) >> > >{ >> > > System.out.println( "Found " + searchHit.toString() ); >> > > System.out.println("time" + searchHit.getProperty("time")); >> > > } >> > > >> > > tx.success(); >> > > } finally { >> > > tx.finish(); >> > > } >> > > } >> > > } >> > > >> > > On Wed, Sep 22, 2010 at 11:15 PM, Andreas Ronge < >> andreas.ro...@jayway.se >> > >wrote: >> > > >> > >> Hi >> > >> >> > >> In the example >> > >> >> > >> https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java >> > >> I only see how to sort by Sort.RELEVANCE and Sort.INDEXORDER. >> > >> How do I sort ascending/ on different fields ? >> > >> >> > >> Another related question, how does neo4j work with the new improved >> > >> numerical capabilities of lucene 3.0. >> > >> Example if I add an integer with >> > >> org.neo4j.graphdb.index.Index.add(entity, key, integer_value) will it >> > >> be index as a NumericField so that I (how?) can use >> > >> NumericRangeQueries ? >> > >> >> > >> (In old lucene one had to convert integers to strings and pad it with >> > >> zeros) >> > >> >> > >> Cheers >> > >> Andres >> > >> ___ >> > >> Neo4j mailing list >> > >> User@lists.neo4j.org >> > >> https://lists.neo4j.org/mailman/listinfo/user >> > >> >> > > ___ >> > > Neo4j mailing list >> > > User@lists.neo4j.org >> > > https://lists.neo4j.org/mailman/listinfo/user >> > > >> > ___ >> > Neo4j mailing list >> > User@lists.neo4j.org >> > https://lists.neo4j.org/mailman/listinfo/user >> > >> ___ >> Neo4j mailing list >> User@lists.neo4j.org >> https://lists.neo4j.org/mailman/listinfo/user >> > > > > -- > Mattias Persson, [matt...@neotechnology.com] > Hacker, Neo Technology > www.neotechnology.com > -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
It doesn't try to use NumericField... maybe that can be done somehow so that range queries can more easily be asked, I'll add that as a ticket 2010/9/23 Paddy > Hi Andreas, > Yes it looks like you don't need to wrap it in a padded string. > I tried using myIndex.add(ndOne, "time",1f); it will stills work. > thanks > Paddy > > On Thu, Sep 23, 2010 at 12:37 AM, Andreas Ronge >wrote: > > > Hi Paddy > > > > Thanks for the response. > > But it would be nice to avoid wrapping integer or float values in > > padded strings, as you described in your example: > > > Node ndOne = gds.createNode(); > > > ndOne.setProperty("time", "1.3"); > > >myIndex.add(ndOne, "time", ndOne.getProperty("time") ); > > Instead I believe it's possible in Lucene 3.0 to index the time > > property as a float. The question is if this feature is exposed in the > > Neo4j Lucene API ? > > > > Cheers > > Andreas > > > > > > On Thu, Sep 23, 2010 at 8:43 AM, Paddy wrote: > > > Hi Andres, > > > Not sure about the use of sorting but I have previously tried some > > numeric > > > range queries with the new indexProvider. > > > I've added my some test code i used below. > > > > > > > > > Cheers > > > Paddy > > > > > > public class indexTest { > > > static GraphDatabaseService gds; > > > static IndexProvider provider; > > > > > > @BeforeClass > > > public static void setup() { > > > gds = new EmbeddedGraphDatabase("data/neodb/neodb-tmp"); > > >provider = new LuceneIndexProvider( gds ); > > > } > > > > > > @Test > > > public void fullTextIndex() { > > > Transaction tx = gds.beginTx(); > > > try { > > > Node ndOne = gds.createNode(); > > > ndOne.setProperty("time", "1.3"); > > > Node ndTwo = gds.createNode(); > > > ndTwo.setProperty("time", "1.5"); > > > Node ndThree = gds.createNode(); > > > ndThree.setProperty("time", "2.0"); > > > Node ndFour = gds.createNode(); > > > ndFour.setProperty("time", "3.0"); > > > Node ndFive = gds.createNode(); > > > ndFive.setProperty("time", "5.0"); > > > > > >Index myIndex = provider.nodeIndex( "fulltext", > > > LuceneIndexProvider.FULLTEXT_CONFIG ); > > >myIndex.add(ndOne, "time", ndOne.getProperty("time") ); > > >myIndex.add(ndTwo, "time", ndTwo.getProperty("time") ); > > >myIndex.add(ndThree,"time", ndThree.getProperty("time") ); > > >myIndex.add(ndFour, "time", ndFour.getProperty("time") ); > > >myIndex.add(ndFive, "time", ndFive.getProperty("time") ); > > > > > >for ( Node searchHit : myIndex.query( "time:[1.5 TO 4.3]" ) ) > > >{ > > > System.out.println( "Found " + searchHit.toString() ); > > > System.out.println("time" + searchHit.getProperty("time")); > > > } > > > > > > tx.success(); > > > } finally { > > > tx.finish(); > > > } > > > } > > > } > > > > > > On Wed, Sep 22, 2010 at 11:15 PM, Andreas Ronge < > andreas.ro...@jayway.se > > >wrote: > > > > > >> Hi > > >> > > >> In the example > > >> > > > https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java > > >> I only see how to sort by Sort.RELEVANCE and Sort.INDEXORDER. > > >> How do I sort ascending/ on different fields ? > > >> > > >> Another related question, how does neo4j work with the new improved > > >> numerical capabilities of lucene 3.0. > > >> Example if I add an integer with > > >> org.neo4j.graphdb.index.Index.add(entity, key, integer_value) will it > > >> be index as a NumericField so that I (how?) can use > > >> NumericRangeQueries ? > > >> > > >> (In old lucene one had to convert integers to strings and pad it with > > >> zeros) > > >> > > >> Cheers > > >> Andres > > >> ___ > > >> Neo4j mailing list > > >> User@lists.neo4j.org > > >> https://lists.neo4j.org/mailman/listinfo/user > > >> > > > ___ > > > Neo4j mailing list > > > User@lists.neo4j.org > > > https://lists.neo4j.org/mailman/listinfo/user > > > > > ___ > > Neo4j mailing list > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > > > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
Hi Andreas, Yes it looks like you don't need to wrap it in a padded string. I tried using myIndex.add(ndOne, "time",1f); it will stills work. thanks Paddy On Thu, Sep 23, 2010 at 12:37 AM, Andreas Ronge wrote: > Hi Paddy > > Thanks for the response. > But it would be nice to avoid wrapping integer or float values in > padded strings, as you described in your example: > > Node ndOne = gds.createNode(); > > ndOne.setProperty("time", "1.3"); > >myIndex.add(ndOne, "time", ndOne.getProperty("time") ); > Instead I believe it's possible in Lucene 3.0 to index the time > property as a float. The question is if this feature is exposed in the > Neo4j Lucene API ? > > Cheers > Andreas > > > On Thu, Sep 23, 2010 at 8:43 AM, Paddy wrote: > > Hi Andres, > > Not sure about the use of sorting but I have previously tried some > numeric > > range queries with the new indexProvider. > > I've added my some test code i used below. > > > > > > Cheers > > Paddy > > > > public class indexTest { > > static GraphDatabaseService gds; > > static IndexProvider provider; > > > > @BeforeClass > > public static void setup() { > > gds = new EmbeddedGraphDatabase("data/neodb/neodb-tmp"); > >provider = new LuceneIndexProvider( gds ); > > } > > > > @Test > > public void fullTextIndex() { > > Transaction tx = gds.beginTx(); > > try { > > Node ndOne = gds.createNode(); > > ndOne.setProperty("time", "1.3"); > > Node ndTwo = gds.createNode(); > > ndTwo.setProperty("time", "1.5"); > > Node ndThree = gds.createNode(); > > ndThree.setProperty("time", "2.0"); > > Node ndFour = gds.createNode(); > > ndFour.setProperty("time", "3.0"); > > Node ndFive = gds.createNode(); > > ndFive.setProperty("time", "5.0"); > > > >Index myIndex = provider.nodeIndex( "fulltext", > > LuceneIndexProvider.FULLTEXT_CONFIG ); > >myIndex.add(ndOne, "time", ndOne.getProperty("time") ); > >myIndex.add(ndTwo, "time", ndTwo.getProperty("time") ); > >myIndex.add(ndThree,"time", ndThree.getProperty("time") ); > >myIndex.add(ndFour, "time", ndFour.getProperty("time") ); > >myIndex.add(ndFive, "time", ndFive.getProperty("time") ); > > > >for ( Node searchHit : myIndex.query( "time:[1.5 TO 4.3]" ) ) > >{ > > System.out.println( "Found " + searchHit.toString() ); > > System.out.println("time" + searchHit.getProperty("time")); > > } > > > > tx.success(); > > } finally { > > tx.finish(); > > } > > } > > } > > > > On Wed, Sep 22, 2010 at 11:15 PM, Andreas Ronge >wrote: > > > >> Hi > >> > >> In the example > >> > https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java > >> I only see how to sort by Sort.RELEVANCE and Sort.INDEXORDER. > >> How do I sort ascending/ on different fields ? > >> > >> Another related question, how does neo4j work with the new improved > >> numerical capabilities of lucene 3.0. > >> Example if I add an integer with > >> org.neo4j.graphdb.index.Index.add(entity, key, integer_value) will it > >> be index as a NumericField so that I (how?) can use > >> NumericRangeQueries ? > >> > >> (In old lucene one had to convert integers to strings and pad it with > >> zeros) > >> > >> Cheers > >> Andres > >> ___ > >> Neo4j mailing list > >> User@lists.neo4j.org > >> https://lists.neo4j.org/mailman/listinfo/user > >> > > ___ > > Neo4j mailing list > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > > > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
Hi Paddy Thanks for the response. But it would be nice to avoid wrapping integer or float values in padded strings, as you described in your example: > Node ndOne = gds.createNode(); > ndOne.setProperty("time", "1.3"); > myIndex.add(ndOne, "time", ndOne.getProperty("time") ); Instead I believe it's possible in Lucene 3.0 to index the time property as a float. The question is if this feature is exposed in the Neo4j Lucene API ? Cheers Andreas On Thu, Sep 23, 2010 at 8:43 AM, Paddy wrote: > Hi Andres, > Not sure about the use of sorting but I have previously tried some numeric > range queries with the new indexProvider. > I've added my some test code i used below. > > > Cheers > Paddy > > public class indexTest { > static GraphDatabaseService gds; > static IndexProvider provider; > > @BeforeClass > public static void setup() { > gds = new EmbeddedGraphDatabase("data/neodb/neodb-tmp"); > provider = new LuceneIndexProvider( gds ); > } > > @Test > public void fullTextIndex() { > Transaction tx = gds.beginTx(); > try { > Node ndOne = gds.createNode(); > ndOne.setProperty("time", "1.3"); > Node ndTwo = gds.createNode(); > ndTwo.setProperty("time", "1.5"); > Node ndThree = gds.createNode(); > ndThree.setProperty("time", "2.0"); > Node ndFour = gds.createNode(); > ndFour.setProperty("time", "3.0"); > Node ndFive = gds.createNode(); > ndFive.setProperty("time", "5.0"); > > Index myIndex = provider.nodeIndex( "fulltext", > LuceneIndexProvider.FULLTEXT_CONFIG ); > myIndex.add(ndOne, "time", ndOne.getProperty("time") ); > myIndex.add(ndTwo, "time", ndTwo.getProperty("time") ); > myIndex.add(ndThree,"time", ndThree.getProperty("time") ); > myIndex.add(ndFour, "time", ndFour.getProperty("time") ); > myIndex.add(ndFive, "time", ndFive.getProperty("time") ); > > for ( Node searchHit : myIndex.query( "time:[1.5 TO 4.3]" ) ) > { > System.out.println( "Found " + searchHit.toString() ); > System.out.println("time" + searchHit.getProperty("time")); > } > > tx.success(); > } finally { > tx.finish(); > } > } > } > > On Wed, Sep 22, 2010 at 11:15 PM, Andreas Ronge > wrote: > >> Hi >> >> In the example >> https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java >> I only see how to sort by Sort.RELEVANCE and Sort.INDEXORDER. >> How do I sort ascending/ on different fields ? >> >> Another related question, how does neo4j work with the new improved >> numerical capabilities of lucene 3.0. >> Example if I add an integer with >> org.neo4j.graphdb.index.Index.add(entity, key, integer_value) will it >> be index as a NumericField so that I (how?) can use >> NumericRangeQueries ? >> >> (In old lucene one had to convert integers to strings and pad it with >> zeros) >> >> Cheers >> Andres >> ___ >> Neo4j mailing list >> User@lists.neo4j.org >> https://lists.neo4j.org/mailman/listinfo/user >> > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
Hi Andres, Not sure about the use of sorting but I have previously tried some numeric range queries with the new indexProvider. I've added my some test code i used below. Cheers Paddy public class indexTest { static GraphDatabaseService gds; static IndexProvider provider; @BeforeClass public static void setup() { gds = new EmbeddedGraphDatabase("data/neodb/neodb-tmp"); provider = new LuceneIndexProvider( gds ); } @Test public void fullTextIndex() { Transaction tx = gds.beginTx(); try { Node ndOne = gds.createNode(); ndOne.setProperty("time", "1.3"); Node ndTwo = gds.createNode(); ndTwo.setProperty("time", "1.5"); Node ndThree = gds.createNode(); ndThree.setProperty("time", "2.0"); Node ndFour = gds.createNode(); ndFour.setProperty("time", "3.0"); Node ndFive = gds.createNode(); ndFive.setProperty("time", "5.0"); Index myIndex = provider.nodeIndex( "fulltext", LuceneIndexProvider.FULLTEXT_CONFIG ); myIndex.add(ndOne, "time", ndOne.getProperty("time") ); myIndex.add(ndTwo, "time", ndTwo.getProperty("time") ); myIndex.add(ndThree,"time", ndThree.getProperty("time") ); myIndex.add(ndFour, "time", ndFour.getProperty("time") ); myIndex.add(ndFive, "time", ndFive.getProperty("time") ); for ( Node searchHit : myIndex.query( "time:[1.5 TO 4.3]" ) ) { System.out.println( "Found " + searchHit.toString() ); System.out.println("time" + searchHit.getProperty("time")); } tx.success(); } finally { tx.finish(); } } } On Wed, Sep 22, 2010 at 11:15 PM, Andreas Ronge wrote: > Hi > > In the example > https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java > I only see how to sort by Sort.RELEVANCE and Sort.INDEXORDER. > How do I sort ascending/ on different fields ? > > Another related question, how does neo4j work with the new improved > numerical capabilities of lucene 3.0. > Example if I add an integer with > org.neo4j.graphdb.index.Index.add(entity, key, integer_value) will it > be index as a NumericField so that I (how?) can use > NumericRangeQueries ? > > (In old lucene one had to convert integers to strings and pad it with > zeros) > > Cheers > Andres > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
[Neo4j] How do I sort Lucene results by field value, and numerical range queries ?
Hi In the example https://svn.neo4j.org/laboratory/components/lucene-index/trunk/src/test/java/org/neo4j/index/impl/lucene/TestLuceneIndex.java I only see how to sort by Sort.RELEVANCE and Sort.INDEXORDER. How do I sort ascending/ on different fields ? Another related question, how does neo4j work with the new improved numerical capabilities of lucene 3.0. Example if I add an integer with org.neo4j.graphdb.index.Index.add(entity, key, integer_value) will it be index as a NumericField so that I (how?) can use NumericRangeQueries ? (In old lucene one had to convert integers to strings and pad it with zeros) Cheers Andres ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user