Zeta Components - high quality PHP components

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

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.

Exceptions:
Type Description
ezcSearchTransactionException if no transaction is active.

createDeleteQuery

ezcSearchDeleteQuery createDeleteQuery( 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->bindValue( 15 ) ) );
  3.  $session->delete( $q );
Parameters:
Name Type Description
$type string
Exceptions:
Type Description
ezcSearchException if there is no such document type.

createFindQuery

ezcSearchFindQuery createFindQuery( 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
Exceptions:
Type Description
ezcSearchException if there is no such document type.

delete

void delete( ezcSearchDeleteQuery $query )

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

void deleteById( mixed $id , string $type )

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:

  1.  $q = $session->createFindQuery();
  2.  $allPersons = $session->find( $q );
Parameters:
Name Type Description
$query ezcSearchQuery
Exceptions:
Type Description
ezcSearchQueryException if the find query failed.
ezcSearchDefinitionNotFoundException if there is no such persistent class.

findById

ezcSearchResult findById( mixed $id , string $type )

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

void index( object $document )

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

void update( object $document )

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.
Documentation generated by phpDocumentor 1.4.3