org.compass.core
Interface CompassSearchSession

All Known Subinterfaces:
CompassSession, InternalCompassSession
All Known Implementing Classes:
DefaultCompassSession, ExistingCompassSession

public interface CompassSearchSession

A specialized interface that provides only search and read capabilities.

Using the session depends on how transaction managemnet should be done (also see Compass.openSearchSession(). The simplest form looks like this:

 CompassSearchSession session = compass.openSearchSession();
 try {
      // do search operations
 } finally {
      session.close();
 }
 

Author:
kimchy

Method Summary
 CompassAnalyzerHelper analyzerHelper()
          Returns an Analyzer helper.
 void close()
          Closes the search session.
 CompassHits find(String query)
          Finds a list of objects that match the specified query.
<T> T
get(Class<T> clazz, Object... ids)
          Returns an object that match the mapping specified for the defined class, and matches the specified ids.
<T> T
get(Class<T> clazz, Object id)
          Returns an object that match the mapping specified for the defined class, and matches the specified id.
 Object get(String alias, Object... ids)
          Returns an object that match the mapping specified for the defined alias, and matches the specified ids.
 Object get(String alias, Object id)
          Returns an object that match the mapping specified for the defined alias, and matches the specified id.
 Resource getResource(Class clazz, Object... ids)
          Returns a Resource that match the mapping specified for the defined class type, and specified ids.
 Resource getResource(Class clazz, Object id)
          Returns a Resource that match the mapping specified for the defined class type, and specified id.
 Resource getResource(String alias, Object... ids)
          Returns a Resource that match the mapping specified for the defined alias (possibley different object types), and matches the specified ids.
 Resource getResource(String alias, Object id)
          Returns a Resource that match the mapping specified for the defined alias (possibley different object types), and matches the specified id.
 CompassSettings getSettings()
          Runtimes settings that apply on the session level.
<T> T
load(Class<T> clazz, Object... ids)
          Loads and returns an object that match the mapping specified for the defined class, and matches the specified ids.
<T> T
load(Class<T> clazz, Object id)
          Loads and returns an object that match the mapping specified for the defined class, and matches the specified id.
 Object load(String alias, Object... ids)
          Loads and returns an object that match the mapping specified for the defined class, and matches the specified ids.
 Object load(String alias, Object id)
          Loads and returns an object that match the mapping specified for the defined class, and matches the specified id.
 Resource loadResource(Class clazz, Object... ids)
          Loads and returns a Resource that match the mapping specified for the defined class, and matches the specified ids.
 Resource loadResource(Class clazz, Object id)
          Loads and returns a Resource that match the mapping specified for the defined class, and matches the specified id.
 Resource loadResource(String alias, Object... ids)
          Loads and returns a Resource that match the mapping specified for the defined alias, and matches the specified ids.
 Resource loadResource(String alias, Object id)
          Loads and returns a Resource that match the mapping specified for the defined alias, and matches the specified id.
 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.
 CompassTermFreqsBuilder termFreqsBuilder(String... names)
          Creates a new terms frequencies builder used to get terms names and freqs for a list of property names.
 CompassSearchSession useLocalTransaction()
          When not using the CompassTransaction interface, will begin a local transaction instead of the configured transaction.
 

Method Detail

getSettings

CompassSettings getSettings()
Runtimes settings that apply on the session level.

Returns:
Runtime settings applies on the session level

useLocalTransaction

CompassSearchSession useLocalTransaction()
When not using the CompassTransaction interface, will begin a local transaction instead of the configured transaction.


getResource

Resource getResource(Class clazz,
                     Object id)
                     throws CompassException
Returns a Resource that match the mapping specified for the defined class type, and specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The resource, returns null if not found
Throws:
CompassException

getResource

Resource getResource(Class clazz,
                     Object... ids)
                     throws CompassException
Returns a Resource that match the mapping specified for the defined class type, and specified ids.

Parameters:
clazz - The class that represents the required mapping
ids - The ids that identifies the resource
Returns:
The resource, returns null if not found
Throws:
CompassException

getResource

Resource getResource(String alias,
                     Object id)
                     throws CompassException
Returns a Resource that match the mapping specified for the defined alias (possibley different object types), and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The resource
Throws:
CompassException

getResource

Resource getResource(String alias,
                     Object... ids)
                     throws CompassException
Returns a Resource that match the mapping specified for the defined alias (possibley different object types), and matches the specified ids. Returns null if the object is not found.

Parameters:
alias - The alias that represents the required mapping
ids - The ids that identifies the resource
Returns:
The resource
Throws:
CompassException

loadResource

Resource loadResource(Class clazz,
                      Object id)
                      throws CompassException
Loads and returns a Resource that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The resource
Throws:
CompassException

loadResource

Resource loadResource(Class clazz,
                      Object... ids)
                      throws CompassException
Loads and returns a Resource that match the mapping specified for the defined class, and matches the specified ids. Throws an exception if the resource is not found.

Parameters:
clazz - The class that represents the required mapping
ids - The ids that identifies the resource
Returns:
The resource
Throws:
CompassException

loadResource

Resource loadResource(String alias,
                      Object id)
                      throws CompassException
Loads and returns a Resource that match the mapping specified for the defined alias, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The resource
Throws:
CompassException

loadResource

Resource loadResource(String alias,
                      Object... ids)
                      throws CompassException
Loads and returns a Resource that match the mapping specified for the defined alias, and matches the specified ids. Throws an exception if the resource is not found.

Parameters:
alias - The alias that represents the required mapping
ids - The ids that identifies the resource
Returns:
The resource
Throws:
CompassException

get

<T> T get(Class<T> clazz,
          Object id)
      throws CompassException
Returns an object that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The object, returns null if not found
Throws:
CompassException

get

<T> T get(Class<T> clazz,
          Object... ids)
      throws CompassException
Returns an object that match the mapping specified for the defined class, and matches the specified ids. Returns null if the object is not found.

Parameters:
clazz - The class that represents the required mapping
ids - The ids that identifies the resource
Returns:
The object, returns null if not found
Throws:
CompassException

get

Object get(String alias,
           Object id)
           throws CompassException
Returns an object that match the mapping specified for the defined alias, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The object, returns null if not found
Throws:
CompassException

get

Object get(String alias,
           Object... ids)
           throws CompassException
Returns an object that match the mapping specified for the defined alias, and matches the specified ids. Returns null if the object is not found.

Parameters:
alias - The alias that represents the required mapping
ids - The ids that identifies the resource
Returns:
The object, returns null if not found
Throws:
CompassException

load

<T> T load(Class<T> clazz,
           Object id)
       throws CompassException
Loads and returns an object that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The object
Throws:
CompassException

load

<T> T load(Class<T> clazz,
           Object... ids)
       throws CompassException
Loads and returns an object that match the mapping specified for the defined class, and matches the specified ids.

Parameters:
clazz - The class that represents the required mapping
ids - The ids that identifies the resource
Returns:
The object
Throws:
CompassException

load

Object load(String alias,
            Object id)
            throws CompassException
Loads and returns an object that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The object
Throws:
CompassException

load

Object load(String alias,
            Object... ids)
            throws CompassException
Loads and returns an object that match the mapping specified for the defined class, and matches the specified ids.

Parameters:
alias - The alias that represents the required mapping
ids - The ids that identifies the resource
Returns:
The object
Throws:
CompassException

find

CompassHits find(String query)
                 throws CompassException
Finds a list of objects that match the specified query. The query syntax is a search engine format query. For detailed description of the query syntax please visit the site.

Several examples are:

Note that the list may contains several object types (classes) with no relation between them (except for the semantic relation).

Parameters:
query - The query string to search by
Returns:
A hits of objects that matches the query string
Throws:
CompassException

queryBuilder

CompassQueryBuilder queryBuilder()
                                 throws CompassException
Creats a new query builder, used to build queries programmatically.

Returns:
The query builder.
Throws:
CompassException

queryFilterBuilder

CompassQueryFilterBuilder queryFilterBuilder()
                                             throws CompassException
Creats a new query filter builder, used to build filters of queries programmatically.

Returns:
The query filter builder.
Throws:
CompassException

termFreqsBuilder

CompassTermFreqsBuilder termFreqsBuilder(String... names)
                                         throws CompassException
Creates a new terms frequencies builder used to get terms names and freqs for a list of property names.

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

Parameters:
names - The property names
Returns:
A term freqs builder
Throws:
CompassException

analyzerHelper

CompassAnalyzerHelper analyzerHelper()
                                     throws CompassException
Returns an Analyzer helper. Can be used to help analyze given texts.

Returns:
the analyzer helper
Throws:
CompassException

close

void close()
Closes the search session.



Copyright (c) 2004-2009 The Compass Project.