You can do that out of the box. If the result size is more than a certain
threshold (100, I think) it gathers the results lazily instead of in the
getNodes method itself. So if you do a query which has lots of hits you can
keep that IndexHits instance with you to do pagination and such with. So
there's really no need to specify max number of hits to return, instead just
iterate over as many as you like and close the IndexHits instance when
you're done. It should still perform very well. If it doesn't please come
back with feedback about it.


/ Mattias

2010/8/27 Honnur Vorvoi <vhon...@yahoo.com>

>
> Thanks Mattias, that was very helpful.
>
> I have another related question:
> Is there a way we can limit the number of search results from the index
> query?
> Basically am looking to implement pagination incase the search results
> return say thousands of records. Are there any better solutions to achieve
> the same?
>
> Would be interested to know your thoughts.
>
> Honnur
>
> --- On Wed, 8/25/10, user-requ...@lists.neo4j.org <
> user-requ...@lists.neo4j.org> wrote:
>
> Date: Wed, 25 Aug 2010 10:28:10 +0200
> From: Mattias Persson <matt...@neotechnology.com>
> Subject: Re: [Neo4j] Index search with more than one key
> To: Neo4j user discussions <user@lists.neo4j.org>
> Message-ID:
>     <aanlktinn0fisdaaxbiyd2-kcrebmyt9glqysm_dgx...@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> There's a prototype implementation of a new index which solves this (and
> some other issues as well, f.ex. indexing for relationships). The code is
> at
> https://svn.neo4j.org/laboratory/components/lucene-index/ and it's built
> and
> deployed over at http://m2.neo4j.org/org/neo4j/neo4j-lucene-index/
>
> The new index isn't compatible with the old one so you'll have to index
> your
> data with the new index framework to be able to use it.
>
>     IndexProvider provider = new LuceneIndexProvider( graphDb );
>     Index<Node> myIndex = provider.nodeIndex( "users" );
>
>     myIndex.add( myNode, "type", "value1" );
>     myIndex.add( myNode, "key1", "value2" );
>
>     // Ask lucene queries directly here
>     for ( Node searchHit : myIndex.query( "type:value1 AND key1:value2" ) )
>     {
>         System.out.println( "Found " + searchHit );
>     }
>
> 2010/8/25 Honnur Vorvoi <vhon...@yahoo.com>
>
> > Hello,
> >
> > Is there a way we can search nodes based on more than one property key?
> > For ex:
> > Node1:
> > type=value1,
> > key1=value2
> >
> > node2:
> > type=value1,
> > key1=value21
> >
> > node3:
> > type=value2
> > key1=value2
> >
> > node4:
> > type=value1
> > key1=value21
> > key2=value4
> >
> > Let's say type & key1 properties are indexed
> > Any suggestions on how we can get all nodes with type=value1 AND
> > key1=value21 in one call.
> >
> >
> > TIA
> > _______________________________________________
> > 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

Reply via email to