PHP Class Elastica\Type\AbstractType

This abstract model should help creating search index and a subtype with some easy config entries that are overloaded. The following variables have to be set: - $_indexName - $_typeName The following variables can be set for additional configuration - $_mapping: Value type mapping for the given type - $_indexParams: Parameters for the index
Author: Nicolas Ruflin ([email protected])
Inheritance: implements Elastica\SearchableInterface
Show file Open project: ruflin/elastica

Protected Properties

Property Type Description
$_client Client.
$_index Index.
$_indexName Index name.
$_indexParams Index params.
$_mapping Mapping.
$_source Source.
$_type Type.
$_typeName Index name.

Public Methods

Method Description
__construct ( Client $client = null ) Creates index object with client connection.
convertDate ( integer $date ) : string Converts given time to format: 1995-12-31T23:59:59Z.
count ( string | array | Query $query = '' ) : integer Count docs in the type based on query.
create ( boolean $recreate = false ) Creates the index and sets the mapping for this type.
createSearch ( string | Query $query = '', array | integer $options = null ) : Search
getIndex ( ) : Index Returns the search index.
getType ( ) : Type Returns type object.
search ( string | array | Query $query = '', null $options = null ) : ResultSet Search on the type.

Method Details

__construct() public method

Reads index and type name from protected vars _indexName and _typeName. Has to be set in child class
public __construct ( Client $client = null )
$client Elastica\Client OPTIONAL Client object

convertDate() public method

This is the lucene date format
public convertDate ( integer $date ) : string
$date integer Date input (could be string etc.) -> must be supported by strtotime
return string Converted date string

count() public method

Count docs in the type based on query.
See also: Elastica\SearchableInterface::count
public count ( string | array | Query $query = '' ) : integer
$query string | array | Elastica\Query Array with all query data inside or a Elastica\Query object
return integer number of documents matching the query

create() public method

Creates the index and sets the mapping for this type.
public create ( boolean $recreate = false )
$recreate boolean OPTIONAL Recreates the index if true (default = false)

createSearch() public method

public createSearch ( string | Query $query = '', array | integer $options = null ) : Search
$query string | Elastica\Query
$options array | integer
return Elastica\Search

getIndex() public method

Returns the search index.
public getIndex ( ) : Index
return Elastica\Index Index object

getType() public method

Returns type object.
public getType ( ) : Type
return Elastica\Type Type object

Property Details

$_client protected property

Client.
protected $_client

$_index protected property

Index.
protected $_index

$_indexName protected property

Index name.
protected $_indexName

$_indexParams protected property

Index params.
protected $_indexParams

$_mapping protected property

Mapping.
protected $_mapping

$_source protected property

Source.
protected $_source

$_type protected property

Type.
protected $_type

$_typeName protected property

Index name.
protected $_typeName