Search: ezcSearchSession
[ ]
[ Solr schema ]
[ ]
[ ]
[ ]
[ ]
Class: ezcSearchSession
|
ezcSearchSession is the main runtime interface for searching documents. [
source]
Properties
Method Summary
|
public ezcSearchSession |
__construct(
$handler, $manager )
Constructs a new search session that works on the handler $handler. |
|
public void |
beginTransaction(
)
Starts a transaction for indexing. |
|
public void |
commit(
)
Ends a transaction and calls commit. |
|
public ezcSearchDeleteQuery |
createDeleteQuery(
$type, $type
)
Returns a delete query for the given document type $type. |
|
public ezcSearchFindQuery |
createFindQuery(
$type, $type
)
Returns a search query for the given document type $type. |
|
public void |
delete(
$query )
Deletes the document $document from the index. |
|
public void |
deleteById(
$id, $type )
Deletes a document by the document's $id |
|
public ezcSearchResult |
find(
$query, $query
)
Returns the result of the search query $query as a list of objects. |
|
public ezcSearchResult |
findById(
$id, $type )
Find a document by its ID. |
|
public void |
index(
$document )
Indexes the new document $document to the search index. |
|
public void |
update(
$document )
Indexes a new document after removing the old one first. |
Methods
__construct
Constructs a new search session that works on the handler $handler.
The $manager provides valid search document definitions to the session. The $handler will be used to perform all search operations.
Parameters
beginTransaction
void beginTransaction(
)
Starts a transaction for indexing.
When using a transaction, the amount of processing that the search backend does decreases, increasing indexing performance. Without this, the component sends a commit after every document that is indexed. Transactions can be nested, when commit() is called the same number of times as beginTransaction(), the component sends a commit.
commit
void commit(
)
Ends a transaction and calls commit.
Throws
| Class | Description |
ezcSearchTransactionException |
if no transaction is active. |
createDeleteQuery
Returns a delete query for the given document type $type.
Example:
1. $q = $session->createDeleteQuery( 'Person' );
2. $q->where( $q->gt( 'age', $q->bindValue( 15 ) ) );
3. $session->delete( $q );
Parameters
| Name |
Type |
Description |
$type
|
string |
|
$type |
|
|
Throws
| Class | Description |
ezcSearchException |
if there is no such document type. |
createFindQuery
Returns a search query for the given document type $type.
The query is initialized to fetch all properties.
Example:
1. $q = $session->createFindQuery( 'Person' );
2. $allPersons = $session->find( $q, 'Person' );
Parameters
| Name |
Type |
Description |
$type
|
string |
|
$type |
|
|
Throws
| Class | Description |
ezcSearchException |
if there is no such document type. |
delete
Deletes the document $document from the index.
Parameters
Throws
| Class | Description |
ezcSearchDefinitionNotFoundxception |
if the object is not recognized as valid document type. |
ezcSearchDocumentNotAvailableException |
if $document is not stored in the database already |
ezcSearchQueryException |
if the object could not be deleted. |
deleteById
void deleteById(
mixed
$id, string
$type )
Deletes a document by the document's $id
Parameters
| Name |
Type |
Description |
$id |
mixed |
|
$type |
string |
|
Throws
| Class | Description |
ezcSearchException |
if there is no such document type. |
find
Returns the result of the search query $query as a list of objects.
Returns the documents found for document type $type using the submitted $query. $query should be created using
createFindQuery().
Parameters
Throws
| Class | Description |
ezcSearchDefinitionNotFoundException |
if there is no such persistent class. |
ezcSearchQueryException |
if the find query failed. |
findById
Find a document by its ID.
Parameters
| Name |
Type |
Description |
$id |
mixed |
|
$type |
string |
|
Throws
| Class | Description |
ezcSearchException |
if there is no such document type. |
index
void index(
object
$document )
Indexes the new document $document to the search index.
Parameters
| Name |
Type |
Description |
$document |
object |
|
Throws
| Class | Description |
ezcSearchException |
if $document is not of a valid document type. |
ezcSearchException |
if it was not possible to generate a unique identifier for the new object. |
ezcSearchException |
if the indexing failed. |
update
void update(
object
$document )
Indexes a new document after removing the old one first.
Parameters
| Name |
Type |
Description |
$document |
object |
|
Throws
| Class | Description |
ezcSearchDefinitionNotFoundException |
if $document is not of a valid document type. |
ezcSearchDocumentNotAvailableException |
if $document is not stored in the database already. |
Last updated: Tue, 01 Sep 2009