lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: Document-Map, Hits-List
Date Sat, 04 Dec 2004 00:44:01 GMT
Yes, it's not wise to just pull all Document instances from Hits
instance, unless you really need them all.  I don't do that, I really
just provide a wrapper, like this:

/**
 * A simple List implementation wrapping a Hits object.
 *
 * @author Otis Gospodnetic
 * @version $Id: HitList.java,v 1.4 2004/11/11 14:08:33 otis Exp $
 */
public class HitList extends AbstractList
{
    private Hits _hits;

    /**
     * Creates a new <code>HitList</code> instance.
     *
     * @param hits <code>Hits</code> to wrap
     */
    public HitList(Hits hits)
    {
        _hits = hits;
    }

    /**
     * @see java.util.List#get(int)
     */
    public Object get(int index)
    {
        try {
            return _hits.doc(index);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * @see java.util.List#size()
     */
    public int size() {
        return _hits.length();
    }


...
...

Otis


--- Luke Francl <luke.francl@stellent.com> wrote:

> On Wed, 2004-12-01 at 10:27, Otis Gospodnetic wrote:
> 
> > This is very similar to what I do - I create a List of Maps from
> Hits
> > and its Documents.  So I think this change may be handy, if doable
> (I
> > didn't look into changing the two Lucene classes, actually).
> 
> 
> How do you avoid the problem Eric just mentioned, iterating through
> all
> the Hits at once to populate this data structure?
> 
> I do a similar thing, creating a List of asset references from a
> field
> in each Lucene Document in my Hits list (actual data for display
> retrieved from a separate datastore). I was not aware of any
> performance
> problems from doing this, but now I am wondering about the
> implications.
> 
> Thanks,
> Luke
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message