Search: ezcSearchSolrHandler
[ ]
[ Solr schema ]
[ ]
[ ]
[ ]
[ ]
Class: ezcSearchSolrHandler
|
Solr backend implementation [
source]
Implemented Interfaces
Member Variables
|
public resource(stream) |
$connection
Holds the connection to Solr |
Method Summary
|
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 ezcSearchDeleteQuery |
createDeleteQuery(
$type )
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 ezcSearchResult |
delete(
$query )
Builds the delete query and returns the parsed response |
|
public ezcSearchResult |
find(
$query )
Builds the search query and returns the parsed response |
|
public static string |
getName(
)
Returns 'solr'. |
|
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. |
|
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
__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.
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.
Throws
| Class | Description |
ezcSearchTransactionException |
if no transaction is active. |
connect
void connect(
)
Connects to Solr
Throws
| Class | 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 |
|
createFindQuery
Creates a search query object with the fields from the definition filled in.
Parameters
delete
Builds the delete query and returns the parsed response
Parameters
find
Builds the search query and returns the parsed response
Parameters
getName
string getName(
)
Returns 'solr'.
index
Indexes the document $document using definition $definition
Parameters
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 |
|
Throws
| Class | 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 |
|
Throws
| Class | Description |
ezcSearchInvalidValueException |
if an array of values is submitted, but the field has not been defined as a multi-value field. |
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 |
|
Last updated: Tue, 02 Dec 2008