|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface CompassSession
The main interface between a Java application and Compass.
Provides the basic operations with semantic mapped objects (save, delete, and load/get). The session provides operations on both the objects levels and Resource levels (indexed object model). The CompassSession operations are delegated to the underlying SearchEngine, so no direct access to the SearchEngine is needed.
Implementations will not be thread safe, Instead each thread/transaction should obtain its own instance from a Compass.
If the CompassSession throws an exception, the transaction must be rolled back and the session discarded. The internal state of the CompassSession might not be consistent with the search engine if discarded.
Using the session depends on how transaction managemnet should be done (also see
Compass.openSession(). The simplest form looks like this:
CompassSession session = compass.openSession();
try {
// do operations with the session
session.commit(); // same as session.close()
} catch (Exception e) {
session.rollback();
}
A more complex form includes explicit control using CompassTransaction:
CompassSession session = compass.openSession();
CompassTransaction tx = null;
try {
tx = session.beginTransaction();
Object result = compassCallback.doInCompass(session);
tx.commit();
return result;
} catch (RuntimeException e) {
if (tx != null) {
tx.rollback();
}
throw e;
} finally {
session.close();
}
Resource,
Compass| Method Summary | |
|---|---|
CompassAnalyzerHelper |
analyzerHelper()
Returns an Analyzer helper. |
CompassTransaction |
beginLocalTransaction()
Begins a unit of work using a Compass local transaction. |
CompassTransaction |
beginTransaction()
Begin a unit of work and return the associated CompassTranscation object. |
void |
close()
Closes the CompassSession. |
void |
commit()
Same as close(). |
void |
flush()
Flush the current transaction. |
void |
flushCommit(String... aliases)
Flush commit all the provided aliases (or all of them, if none is provided). |
CompassSettings |
getSettings()
Runtimes settings that apply on the session level. |
boolean |
isClosed()
Returns true if the session is closed. |
boolean |
isReadOnly()
Returns true if the session is read only. |
CompassQueryBuilder |
queryBuilder()
Creats a new query builder, used to build queries programmatically. |
CompassQueryFilterBuilder |
queryFilterBuilder()
Creats a new query filter builder, used to build filters of queries programmatically. |
ResourceFactory |
resourceFactory()
Returns a resource factory allowing to create resources and properties. |
void |
rollback()
When not using explicit CompassTransaction in order to manage transactions, can be called
to rollback the current running transaction. |
void |
setReadOnly()
Indicates that the session will be used for read only operations. |
CompassTermFreqsBuilder |
termFreqsBuilder(String... names)
Creates a new terms frequencies builder used to get terms names and freqs for a list of property names. |
CompassSession |
useLocalTransaction()
When not using the CompassTransaction interface, will begin a local transaction
instead of the configured transaction. |
| Methods inherited from interface org.compass.core.CompassOperations |
|---|
create, create, delete, delete, delete, delete, delete, delete, delete, evict, evict, evict, evictAll, find, get, get, get, get, getResource, getResource, getResource, getResource, load, load, load, load, loadResource, loadResource, loadResource, loadResource, save, save |
| Methods inherited from interface org.compass.core.CompassSearchSession |
|---|
find, get, get, get, get, getResource, getResource, getResource, getResource, load, load, load, load, loadResource, loadResource, loadResource, loadResource |
| Methods inherited from interface org.compass.core.CompassIndexSession |
|---|
create, create, delete, delete, delete, delete, delete, delete, delete, save, save |
| Method Detail |
|---|
void setReadOnly()
boolean isReadOnly()
true if the session is read only.
setReadOnly()CompassSession useLocalTransaction()
CompassTransaction interface, will begin a local transaction
instead of the configured transaction.
useLocalTransaction in interface CompassSearchSessionResourceFactory resourceFactory()
resourceFactory in interface CompassIndexSessionCompassSettings getSettings()
getSettings in interface CompassIndexSessiongetSettings in interface CompassSearchSession
void flush()
throws CompassException
flush in interface CompassIndexSessionCompassException
void flushCommit(String... aliases)
throws CompassException
flushCommit in interface CompassIndexSessionCompassException
CompassTransaction beginTransaction()
throws CompassException
compass.transaction.factory.
CompassExceptionCompassTransaction
CompassTransaction beginLocalTransaction()
throws CompassException
CompassException
CompassQueryBuilder queryBuilder()
throws CompassException
queryBuilder in interface CompassSearchSessionCompassException
CompassQueryFilterBuilder queryFilterBuilder()
throws CompassException
queryFilterBuilder in interface CompassSearchSessionCompassException
CompassTermFreqsBuilder termFreqsBuilder(String... names)
throws CompassException
Note, term frequencies are updated to reflect latest changes to the index only after an optimization has taken place (note, calling optimize might not cause optimization).
termFreqsBuilder in interface CompassSearchSessionnames - The property names
CompassException
CompassAnalyzerHelper analyzerHelper()
throws CompassException
analyzerHelper in interface CompassSearchSessionCompassException
void rollback()
throws CompassException
CompassTransaction in order to manage transactions, can be called
to rollback the current running transaction. Effectively also closes the session.
rollback in interface CompassIndexSessionCompassException
void commit()
throws CompassException
close().
commit in interface CompassIndexSessionCompassException
void close()
throws CompassException
If there is an on going transaction associated with the session that has not been committed / rolledback yet, will commit the transaction (and in case of failure, will roll it back). Failed commits will throw an exception from the close method.
close in interface CompassIndexSessionclose in interface CompassSearchSessionCompassExceptionCompass.openSession()boolean isClosed()
true if the session is closed. Note, if this session
"joined" another session, it won't actually be closed, and defer closing
the session to the outer session.
isClosed in interface CompassIndexSession
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||