org.compass.core
Interface CompassHits

All Superinterfaces:
CompassHitsOperations, Iterable<CompassHit>, Serializable
All Known Subinterfaces:
InternalCompassHits
All Known Implementing Classes:
DefaultCompassHits

public interface CompassHits
extends CompassHitsOperations

Holds hits returned from a search performed by compass. Can be used within a transaction context. For hits to be used outside of a transactional context, the detach() and detach(int, int) can be used.

Also allows for highlighting using highlighter(int), and any highlighting operation (that returns a single String) will be cached within the hits (and also moved to the detached hits, if detach(int, int) is called), and can be used by CompassHitsOperations.highlightedText(int).

Author:
kimchy

Method Summary
 void close()
          Closes the hits object.
 CompassDetachedHits detach()
          Detaches a seperate CompassHits, holds all the data.
 CompassDetachedHits detach(int from, int size)
          Detaches a seperate CompassHits, which starts from the given from parameter, and has the specified size.
 CompassHighlighter highlighter(int n)
          Returns the highlighter that maps the n'th hit.
 
Methods inherited from interface org.compass.core.CompassHitsOperations
data, getLength, getQuery, getSuggestedQuery, highlightedText, hit, length, resource, score
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

detach

CompassDetachedHits detach()
                           throws CompassException
Detaches a seperate CompassHits, holds all the data. The detached hits preloads all the data, so it can be used outside of a transaction. NOTE: Be carefull when using the method, since it will take LONG time to load a large hits result set.

Returns:
A detached hits.
Throws:
CompassException

detach

CompassDetachedHits detach(int from,
                           int size)
                           throws CompassException,
                                  IllegalArgumentException
Detaches a seperate CompassHits, which starts from the given from parameter, and has the specified size. The detached hits preloads all the data, so it can be used outside of a transaction.

Parameters:
from - The index that the sub hits starts from.
size - The size of the sub hits.
Returns:
A detached sub hits.
Throws:
CompassException
IllegalArgumentException

highlighter

CompassHighlighter highlighter(int n)
                               throws CompassException
Returns the highlighter that maps the n'th hit.

Note, that any highlighting operation (that returns a single String) will be cached within the hits (and also moved to the detached hits, if detach(int, int) is called), and can be used by CompassHitsOperations.highlightedText(int).

Parameters:
n - The n'th hit.
Returns:
The highlighter.
Throws:
CompassException

close

void close()
           throws CompassException
Closes the hits object. Note that it is an optional operation since it will be closed transperantly when the transaction is closed.

It is provided for more controlled resource management

Throws:
CompassException


Copyright (c) 2004-2008 The Compass Project.