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:
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
Returns 'solr'.
__construct
Creates a new Solr handler connection
Parameters:
Name | Type | Description |
---|---|---|
$host |
string | |
$port |
int | |
$location |
string |
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
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
Connects to Solr
Exceptions:
Type | Description |
---|---|
ezcSearchCanNotConnectException |
if a connection can not be established. |
createDeleteQuery
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
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
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
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
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
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
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
Returns the field name as used by solr created from the field $name and $type.
Parameters:
Name | Type | Description |
---|---|---|
$name |
string | |
$type |
string |
mapFieldValueForIndex
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
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
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
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
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
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
Closes the connection, and re-connects to Solr
Exceptions:
Type | Description |
---|---|
ezcSearchCanNotConnectException |
if a connection can not be established. |
runCommit
Runs a commit command to tell solr we're done indexing.
search
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
Sends the raw command $type to Solr
Parameters:
Name | Type | Description |
---|---|---|
$type |
string | |
$queryString |
array(string=>string) |
sendRawPostCommand
Sends a post command $type to Solr and reads the result
Parameters:
Name | Type | Description |
---|---|---|
$type |
string | |
$queryString |
array(string=>string) | |
$data |
string |