Zeta Components Manual :: Docs For Class ezcSearchSession
Search::ezcSearchSession
Class ezcSearchSession
ezcSearchSession is the main runtime interface for searching documents.
Source for this file: /Search/src/search_session.php
Version: | //autogen// |
Properties
ezcSearchDefinitionManager | read |
$definitionManager
The persistent definition manager set in the constructor. |
ezcSearchHandler | read |
$handler
The handler set in the constructor. |
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
)
Returns a delete query for the given document type $type. |
public ezcSearchFindQuery |
createFindQuery(
$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
)
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:
Name | Type | Description |
---|---|---|
$handler |
ezcSearchHandler | |
$manager |
ezcSearchDefinitionManager |
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
Ends a transaction and calls commit.
Exceptions:
Type | Description |
---|---|
ezcSearchTransactionException |
if no transaction is active. |
createDeleteQuery
Returns a delete query for the given document type $type.
Example:
- $q->where( $q->gt( 'age', $q->bindValue( 15 ) ) );
Parameters:
Name | Type | Description |
---|---|---|
$type |
string |
Exceptions:
Type | 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:
Parameters:
Name | Type | Description |
---|---|---|
$type |
string |
Exceptions:
Type | Description |
---|---|
ezcSearchException |
if there is no such document type. |
delete
Deletes the document $document from the index.
Parameters:
Name | Type | Description |
---|---|---|
$query |
ezcSearchDeleteQuery |
Exceptions:
Type | 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
Deletes a document by the document's $id
Parameters:
Name | Type | Description |
---|---|---|
$id |
mixed | |
$type |
string |
Exceptions:
Type | 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().
Example:
Parameters:
Name | Type | Description |
---|---|---|
$query |
ezcSearchQuery |
Exceptions:
Type | Description |
---|---|
ezcSearchQueryException |
if the find query failed. |
ezcSearchDefinitionNotFoundException |
if there is no such persistent class. |
findById
Find a document by its ID.
Parameters:
Name | Type | Description |
---|---|---|
$id |
mixed | |
$type |
string |
Exceptions:
Type | Description |
---|---|
ezcSearchException |
if there is no such document type. |
index
Indexes the new document $document to the search index.
Parameters:
Name | Type | Description |
---|---|---|
$document |
object |
Exceptions:
Type | 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
Indexes a new document after removing the old one first.
Parameters:
Name | Type | Description |
---|---|---|
$document |
object |
Exceptions:
Type | Description |
---|---|
ezcSearchDocumentNotAvailableException |
if $document is not stored in the database already. |
ezcSearchDefinitionNotFoundException |
if $document is not of a valid document type. |