Path

ez components / documentation / api reference / 2008.2alpha1 / search


eZ Components 2008.2alpha1

Search: ezcSearchSession

[ Tutorial ] [ Solr schema ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcSearchSession

ezcSearchSession is the main runtime interface for searching documents. [source]

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 ezcQueryDelete 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( $document )
Deletes the document $document from the index.
public void deleteFromQuery( $query )
Deletes documents using the query $query.
public ezcSearchResult find( $query, $query )
Returns the result of the search query $query as a list of objects.
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

ezcSearchSession __construct( ezcSearchHandler $handler, ezcSearchDefinitionManager $manager )
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

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

ClassDescription
ezcSearchTransactionException if no transaction is active.

createDeleteQuery

ezcQueryDelete createDeleteQuery( $type, string $type )
Returns a delete query for the given document type $type.
Example:
1.  $q $session->createDeleteQuery'Person' );
2.  $q->where$q->gt'age'$q->bindValue15 ) ) );
3.  $session->deleteFromQuery$q );

Parameters

Name Type Description
$type string  
$type  

Throws

ClassDescription
ezcSearchException if there is no such document type.

createFindQuery

ezcSearchFindQuery createFindQuery( $type, string $type )
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

ClassDescription
ezcSearchException if there is no such document type.

delete

void delete( object $document )
Deletes the document $document from the index.

Parameters

Name Type Description
$document object The document to delete

Throws

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

deleteFromQuery

void deleteFromQuery( ezcSearchDeleteQuery $query )
Deletes documents using the query $query.
The $query should be created using createDeleteQuery().

Parameters

Name Type Description
$query ezcSearchDeleteQuery  

Throws

ClassDescription
ezcSearchQueryException if the delete query failed.

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:
1.  $q $session->createFindQuery();
2.  $allPersons $session->find$q );

Parameters

Name Type Description
$query ezcSearchQuery  
$query ezcSearchQuery  

Throws

ClassDescription
ezcSearchDefinitionNotFoundException if there is no such persistent class.
ezcSearchQueryException if the find query failed.

index

void index( object $document )
Indexes the new document $document to the search index.

Parameters

Name Type Description
$document object  

Throws

ClassDescription
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

ClassDescription
ezcSearchDefinitionNotFoundException if $document is not of a valid document type.
ezcSearchDocumentNotAvailableException if $document is not stored in the database already.

Last updated: Mon, 10 Nov 2008