2010/9/17 Honnur Vorvoi <vhon...@yahoo.com>

> Thanks Mattias for the suggestion.
>
> What if we had a method in  IndexHits<Node> as below.
> ListIterator<Node>  listIterator = IndexHits<Node>.getListIterator()
>
> The ListIterator can traverse in both ways as opposed to Iterator which is
> forward only.
> If that solves the reverse traverse problem for pagination, is there an
> easy way to get a handle to the ListIterator.
> Even better would be to get a handle to the underlying list (ArrayList, in
> this case) so we can go back and forth by List's index value.
> I am interested to know if the underlying implementation can facilitate
> this.
>

I just created these iterators
https://svn.neo4j.org/components/kernel/trunk/src/main/java/org/neo4j/helpers/collection/CachingIterator.javaand
https://svn.neo4j.org/components/kernel/trunk/src/main/java/org/neo4j/helpers/collection/PagingIterator.javawhich
are general purpose and does exactly what you asked for, I hope :)

I haven't added something on the IndexHits interface, but you could try out
using CachingIterator, or even PagingIterator (which is just a
CachingIterator with convenience for handling paging). They can go back and
forth through the results:


    IndexHits<Node> hits = myNodeIndex.query( "some:query" );
    PagingIterator<Node> pages = new PagingIterator( hits, 25 );
    ...
    Iterator<Node> page = pages.nextPage();
    while ( page.hasNext() ) {
        Node node = page.next();
        ...
    }

    // Go to page 10 and iterator through the items in that page
    pages.page( 10 );
    page =pages.nextPage();
    while ( page.hasNext() ) ...


There aren't methods like "go to the last page" or so and it may have to be
added for it to be useful. Try the out and write back what you think about
them.



>
>
>
> Date: Thu, 16 Sep 2010 22:39:10 +0200
> From: Mattias Persson <matt...@neotechnology.com>
> Subject: Re: [Neo4j] IndexProvider question
> To: Neo4j user discussions <user@lists.neo4j.org>
> Message-ID:
>     
> <aanlktinmd6-mrjrjspp92kan+de_bjbw2dp+l3+nt...@mail.gmail.com<aanlktinmd6-mrjrjspp92kan%2bde_bjbw2dp%2bl3%2bnt...@mail.gmail.com>
> >
> Content-Type: text/plain; charset=UTF-8
>
> I'd say wrapping the Iterator from IndexHits in something that you can do
> pagination on would be a good way to go. There could also be such a
> built-in
> iterator in the index component for convenience. So the CachingIterator (or
> whatever it'd be called) would use the underlying IndexHits iterator to
> lazily fetch new results it hasn't already gotten and remember them so that
> consecutive requests for a particular item could be returned instantly, and
> even be able to be positioned at an arbitrary position and iterate from
> there. It's a pretty generic iterator implementation and it'd be fun to
> implement... if I get the time for it.
>
> 2010/9/16 Honnur Vorvoi <vhon...@yahoo.com>
>
> > Thanks a lot Mattias.
> >
> > I was wondering if there's a way in IndexHits<Node> to actually traverse
> > back to search results.
> > I know we can traverse forward the search results.
> >
> > I am trying to implement pagination and I am caching the IndexHits<Node>
> > for the same.
> > Say, I have already moved to the node #30, but want to return to node#20
> to
> > 25.
> > Obviously I dont want to cache all the search results and I like the lazy
> > loading feature in IndexHits<Node>
> >
> >
> > Date: Wed, 15 Sep 2010 14:16:09 +0200
> > From: Mattias Persson <matt...@neotechnology.com>
> > Subject: Re: [Neo4j] IndexProvider question
> > To: Neo4j user discussions <user@lists.neo4j.org>
> > Message-ID:
> >     <aanlkti=xmdkstyk8l49m1uiqaxroxgrq2rcv004aj...@mail.gmail.com>
> > Content-Type: text/plain; charset=UTF-8
> >
> > I just added a way to do this (not as a persistent config, since they
> > control write behaviour), but instead as an addition to QueryContext. So
> > you
> > can do like this:
> >
> >     myNodeIndex.query( new QueryContext( "name:Mattias
> > occupation:developer"
> > ).defaultOperator( Operator.AND ) );
> >
> > I know it's a bit verbose, but it's a start at least. Grab the latest
> > version and try it out to see if it works for you.
> >
> > 2010/9/10 Mattias Persson <matt...@neotechnology.com>
> >
> > > 2010/9/10, Honnur Vorvoi <vhon...@yahoo.com>:
> > > > I would like to set AND as the default operator when I create index
> > using
> > > > the new index library:
> > > > Index = indexProvider.nodeIndex( "fulltext",
> > > > LuceneIndexProvider.FULLTEXT_CONFIG );
> > > >
> > > > I didn't find "setDefaultOperator" (similar to the one
> > > > in LuceneFulltextQueryIndexService )in any of the provider classes.
> > > > Is it supported in the new index provider? if not, is there a way we
> > can
> > > set
> > > > the same?
> > > >
> > > > Thanks in advance.
> > >
> > > That functionality is easy to add, I just haven't gotten around to do
> > > it. I'll try to add that as soon as possible. Excellent feedback on
> > > the new IndexProvider framework, keep it coming!
> > >
> > > >
> > > >
> > > > --- On Thu, 9/9/10, Honnur Vorvoi <vhon...@yahoo.com> wrote:
> > > >
> > > >
> > > > From: Honnur Vorvoi <vhon...@yahoo.com>
> > > > Subject: Re: [Neo4j] IndexProvider question
> > > > To: user@lists.neo4j.org
> > > > Date: Thursday, September 9, 2010, 10:33 PM
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Thanks Mattias.
> > > > Since IndexProvider does all LuceneFulltextQueryIndexService can do
> and
> > > much
> > > > more, I am going to use just IndexProvider.
> > > >
> > > >
> > > > Date: Wed, 8 Sep 2010 16:28:56 +0200
> > > > From: Mattias Persson <matt...@neotechnology.com>
> > > > Subject: Re: [Neo4j] IndexProvider question
> > > > To: Neo4j user discussions <user@lists.neo4j.org>
> > > > Message-ID:
> > > >     <aanlktin4cjw=smw00=1nlkt8ftmys6xtnvtrve_j9...@mail.gmail.com>
> > > > Content-Type: text/plain; charset=UTF-8
> > > >
> > > > Hi Honnur!
> > > >
> > > > 2010/9/6, Honnur Vorvoi <vhon...@yahoo.com>:
> > > >> Hello,
> > > >>
> > > >> I have the following questions with regard to the
> > IndexProvider(example
> > > >> below):
> > > >>
> > > >> 1. I already have LuceneFulltextQueryIndexService. Can I use
> > > IndexProvider
> > > >> with the same graphDb as well? or are they mutually exclusive?
> > > >
> > > > They are separate from one another so both can be used alongside of
> > > > each other. Something stored in one of either
> > > > LuceneIndexService/LuceneIndexProvider won't affect the other.
> > > >
> > > >> 2. What doesn the param "users" in provider.nodeIndex("users")
> > > represent?
> > > >
> > > > The LuceneIndexService can only keep values from one key in each
> > > > index, but the new LuceneIndexProvider can spawn indexes which can
> > > > contain any number of keys and values (making compound queries
> > > > possible). Since an index isn't tied to a property key you must name
> > > > each index yourself. Each index can also be configured to be either
> > > > fulltext or not, to use lower case conversion or not, a.s.o.
> > > >
> > > >> 3. Do I need to add all the properties in Index<Node>(line# 4&5) in
> > > order
> > > >> to
> > > >> query? (I have already index the same properties with
> > > >> LuceneFulltextQueryIndexService)
> > > >>
> > > > see my answer for (1), in short: LuceneIndexProvider and the indexes
> > > > it spawns has nothing to do with LuceneIndexService (or any
> derivative
> > > > thereof) and hence can't share state.
> > > >
> > > >> 4. Is it easy to include the query(String) method in
> > > >> LuceneFulltextQueryIndexService, so I can use just one indexservice
> > > >> otherwise I would be using LuceneIndexProvider just for
> query(String)
> > > >> method.
> > > >
> > > > To add compound querying the storage format (i.e. Lucene usage)
> needed
> > > > to change in incompatible ways, so it isn't an easy fix to add that.
> > > > It could however be done by querying multiple indexes in parallell
> and
> > > > merge the results afterwards, but I don't think performance would be
> > > > anywhere near using Lucene the "right way" for compound queries, as
> > > > LuceneIndexProvider does.
> > > >
> > > >>
> > > >> As alwasy, appreciate your suggestions/recommendations
> > > >>
> > > >>
> > > >> 1     IndexProvider provider = new LuceneIndexProvider( graphDb );
> > > >> 2     Index<Node> myIndex = provider.nodeIndex( "users" );
> > > >> 3
> > > >> 4     myIndex.add( myNode, "type", "value1" );
> > > >> 5     myIndex.add( myNode, "key1", "value2" );
> > > >> 6
> > > >> 7     // Ask lucene queries directly here
> > > >> 8     for ( Node searchHit : myIndex.query( "type:value1 AND
> > > key1:value2"
> > > >> )
> > > >> )
> > > >> 9     {
> > > >> 10         System.out.println( "Found " + searchHit );
> > > >> 11     }
> > > >> _______________________________________________
> > > >> 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
> > > >
> > >
> > >
> > > --
> > > 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
>



-- 
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