## Apache Zeta Components Manual :: Docs For Class ezcSearchSolrHandler

### Search::ezcSearchSolrHandler

### Class ezcSearchSolrHandler

Solr backend implementation

Source for this file: /Search/src/handlers/solr.php

### Implements interfaces:

- ezcSearchHandler
- ezcSearchIndexHandler

Version: | //autogentag//

### Member Variables

public resource(stream) | `$connection` Holds the connection to Solr

### Method Summary

public static string | `getName( )` Returns 'solr'.
public ezcSearchSolrHandler | `__construct( [ $host = 'localhost'] , [ $port = 8983] , [ $location = '/solr'] )` Creates a new Solr handler connection
public void | `beginTransaction( )` Starts a transaction for indexing.
public void | `commit( )` Ends a transaction and calls commit.
protected void | `connect( )` Connects to Solr
public ezcSearchDeleteQuerySolr | `createDeleteQuery( $type , $definition )` Creates a delete query object with the fields from the definition filled in.
public ezcSearchFindQuery | `createFindQuery( $type , $definition )` Creates a search query object with the fields from the definition filled in.
public void | `delete( $query )` Deletes documents using the query $query.
public void | `deleteById( $id , $definition )` Deletes a document by the document's $id
public ezcSearchResult | `find( $query )` Builds the search query and returns the parsed response
public ezcSearchResult | `findById( $id , $definition )` Finds a document by the document's $id
public void | `index( $definition , $document )` Indexes the document $document using definition $definition
public string | `mapFieldType( $name , $type )` Returns the field name as used by solr created from the field $name and $type.
public mixed | `mapFieldValueForIndex( $fieldType , $value )` This method prepares a $value before it is passed to the indexer.
public mixed | `mapFieldValueForReturn( $fieldType , $value )` This method prepares a $value before it is passed to the search handler.
public mixed | `mapFieldValueForSearch( $fieldType , $value )` This method prepares a $value before it is passed to the search handler.
public array(mixed) | `mapFieldValuesForIndex( $field , $values )` This method prepares a value or an array of $values before it is passed to the indexer.
public mixed|array(mixed) | `mapFieldValuesForReturn( $field , $values )` This method prepares a value or an array of $values after it has been returned by search handler.
public array(mixed) | `mapFieldValuesForSearch( $field , $values )` This method prepares a value or an array of $values before it is passed to the search handler.
public void | `reConnect( )` Closes the connection, and re-connects to Solr
protected void | `runCommit( )` Runs a commit command to tell solr we're done indexing.
public stdClass | `search( $queryWord , $defaultField , [ $searchFieldList = array()] , [ $returnFieldList = array()] , [ $highlightFieldList = array()] , [ $facetFieldList = array()] , [ $limit = null] , [ $offset = 0] , [ $order = array()] )` Executes a search by building and sending a query and returns the raw result
public string | `sendRawGetCommand( $type , [ $queryString = array()] )` Sends the raw command $type to Solr
public string | `sendRawPostCommand( $type , $queryString , $data )` Sends a post command $type to Solr and reads the result

### Methods

#### getName

static string getName( )

Returns 'solr'.

#### __construct

ezcSearchSolrHandler __construct( [string $host = 'localhost'] , [int $port = 8983] , [string $location = '/solr'] )

Creates a new Solr handler connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`$host` | string |
`$port` | int |
`$location` | string |

#### beginTransaction

void beginTransaction( )

Starts a transaction for indexing.

When using a transaction, the amount of processing that solr 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.

##### Implementation of:

Method | Description
--- | ---
`ezcSearchIndexHandler::beginTransaction()` | Starts a transaction for indexing.

#### commit

void commit( )

Ends a transaction and calls commit.

As transactions can be nested, this method will only call commit when all the nested transactions have been ended.

##### Exceptions:

Type | Description
--- | ---
`ezcSearchTransactionException` | if no transaction is active.

##### Implementation of:

Method | Description
--- | ---
`ezcSearchIndexHandler::commit()` | Ends a transaction and calls commit.

#### connect

void connect( )

Connects to Solr

##### Exceptions:

Type | Description
--- | ---
`ezcSearchCanNotConnectException` | if a connection can not be established.

#### createDeleteQuery

ezcSearchDeleteQuerySolr createDeleteQuery( string $type , ezcSearchDocumentDefinition $definition )

Creates a delete query object with the fields from the definition filled in.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$type` | string |
`$definition` | ezcSearchDocumentDefinition |

##### Implementation of:

Method | Description
--- | ---
`ezcSearchIndexHandler::createDeleteQuery()` | Creates a delete query object with the fields from the definition filled in.

#### createFindQuery

ezcSearchFindQuery createFindQuery( string $type , ezcSearchDocumentDefinition $definition )

Creates a search query object with the fields from the definition filled in.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$type` | string |
`$definition` | ezcSearchDocumentDefinition |

##### Implementation of:

Method | Description
--- | ---
`ezcSearchHandler::createFindQuery()` | Creates a search query object with the fields from the definition filled in.

#### delete

void delete( ezcSearchDeleteQuery $query )

Deletes documents using the query $query.

The $query should be created using createDeleteQuery().

##### Parameters:

Name | Type | Description
--- | --- | ---
`$query` | ezcSearchDeleteQuery |

##### Exceptions:

Type | Description
--- | ---
`ezcSearchQueryException` | if the delete query failed.

##### Implementation of:

Method | Description
--- | ---
`ezcSearchIndexHandler::delete()` | Builds the delete query and returns the parsed response

#### deleteById

void deleteById( mixed $id , ezcSearchDocumentDefinition $definition )

Deletes a document by the document's $id

If the document with ID $id does not exist, no warning is returned.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$id` | mixed |
`$definition` | ezcSearchDocumentDefinition |

##### Implementation of:

Method | Description
--- | ---
`ezcSearchIndexHandler::deleteById()` | Deletes a document by the document's $id

#### find

ezcSearchResult find( ezcSearchFindQuery $query )

Builds the search query and returns the parsed response

##### Parameters:

Name | Type | Description
--- | --- | ---
`$query` | ezcSearchFindQuery |

##### Implementation of:

Method | Description
--- | ---
`ezcSearchHandler::find()` | Builds the search query and returns the parsed response

#### findById

ezcSearchResult findById( mixed $id , ezcSearchDocumentDefinition $definition )

Finds a document by the document's $id

##### Parameters:

Name | Type | Description
--- | --- | ---
`$id` | mixed |
`$definition` | ezcSearchDocumentDefinition |

##### Exceptions:

Type | Description
--- | ---
`ezcSearchIdNotFoundException` | if the document with ID $id did not exist.

##### Implementation of:

Method | Description
--- | ---
`ezcSearchHandler::findById()` | Finds a document by the document's $id

#### index

void index( ezcSearchDocumentDefinition $definition , mixed $document )

Indexes the document $document using definition $definition

##### Parameters:

Name | Type | Description
--- | --- | ---
`$definition` | ezcSearchDocumentDefinition |
`$document` | mixed |

##### Implementation of:

Method | Description
--- | ---
`ezcSearchIndexHandler::index()` | Indexes the document $document using definition $definition

#### mapFieldType

string mapFieldType( string $name , string $type )

Returns the field name as used by solr created from the field $name and $type.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$name` | string |
`$type` | string |

#### mapFieldValueForIndex

mixed mapFieldValueForIndex( string $fieldType , mixed $value )

This method prepares a $value before it is passed to the indexer.

Depending on the $fieldType the $value is modified so that the indexer understands the value.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$fieldType` | string |
`$value` | mixed |

#### mapFieldValueForReturn

mixed mapFieldValueForReturn( string $fieldType , mixed $value )

This method prepares a $value before it is passed to the search handler.

Depending on the $fieldType the $value is modified so that the search handler understands the value.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$fieldType` | string |
`$value` | mixed |

#### mapFieldValueForSearch

mixed mapFieldValueForSearch( string $fieldType , mixed $value )

This method prepares a $value before it is passed to the search handler.

Depending on the $fieldType the $value is modified so that the search handler understands the value.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$fieldType` | string |
`$value` | mixed |

#### mapFieldValuesForIndex

array(mixed) mapFieldValuesForIndex( ezcSearchDocumentDefinitionField $field , mixed $values )

This method prepares a value or an array of $values before it is passed to the indexer.

Depending on the $field the $values is modified so that the search handler understands the value. It will also correctly deal with multi-data fields in the search index.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$field` | ezcSearchDocumentDefinitionField |
`$values` | mixed |

##### Exceptions:

Type | Description
--- | ---
`ezcSearchInvalidValueException` | if an array of values is submitted, but the field has not been defined as a multi-value field.

#### mapFieldValuesForReturn

mixed|array(mixed) mapFieldValuesForReturn( ezcSearchDocumentDefinitionField $field , mixed $values )

This method prepares a value or an array of $values after it has been returned by search handler.

Depending on the $field the $values is modified. It will also correctly deal with multi-data fields in the search index.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$field` | ezcSearchDocumentDefinitionField |
`$values` | mixed |

#### mapFieldValuesForSearch

array(mixed) mapFieldValuesForSearch( ezcSearchDocumentDefinitionField $field , mixed $values )

This method prepares a value or an array of $values before it is passed to the search handler.

Depending on the $field the $values is modified so that the search handler understands the value. It will also correctly deal with multi-data fields in the search index.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$field` | ezcSearchDocumentDefinitionField |
`$values` | mixed |

##### Exceptions:

Type | Description
--- | ---
`ezcSearchInvalidValueException` | if an array of values is submitted, but the field has not been defined as a multi-value field.

#### reConnect

void reConnect( )

Closes the connection, and re-connects to Solr

##### Exceptions:

Type | Description
--- | ---
`ezcSearchCanNotConnectException` | if a connection can not be established.

#### runCommit

void runCommit( )

Runs a commit command to tell solr we're done indexing.

#### search

stdClass search( string $queryWord , string $defaultField , [array(string=>string) $searchFieldList = array()] , [array(string=>string) $returnFieldList = array()] , [array(string=>string) $highlightFieldList = array()] , [array(string=>string) $facetFieldList = array()] , [int $limit = null] , [int $offset = 0] , [array(string=>string) $order = array()] )

Executes a search by building and sending a query and returns the raw result

##### Parameters:

Name | Type | Description
--- | --- | ---
`$queryWord` | string |
`$defaultField` | string |
`$searchFieldList` | array(string=>string) |
`$returnFieldList` | array(string=>string) |
`$highlightFieldList` | array(string=>string) |
`$facetFieldList` | array(string=>string) |
`$limit` | int |
`$offset` | int |
`$order` | array(string=>string) |

#### sendRawGetCommand

string sendRawGetCommand( string $type , [array(string=>string) $queryString = array()] )

Sends the raw command $type to Solr

##### Parameters:

Name | Type | Description
--- | --- | ---
`$type` | string |
`$queryString` | array(string=>string) |

#### sendRawPostCommand

string sendRawPostCommand( string $type , array(string=>string) $queryString , string $data )

Sends a post command $type to Solr and reads the result

##### Parameters:

Name | Type | Description
--- | --- | ---
`$type` | string |
`$queryString` | array(string=>string) |
`$data` | string |

Documentation generated by phpDocumentor 1.4.3