PHP 클래스 Cake\ElasticSearch\Type

A type in elastic search is approximately equivalent to a table or collection in a relational datastore. While an index can have multiple types, this ODM maps each type in an index maps to a class.
상속: implements Cake\Datasource\RepositoryInterface, implements Cake\Event\EventDispatcherInterface, use trait Cake\Event\EventManagerTrait, use trait Cake\Datasource\RulesAwareTrait, use trait Cake\Validation\ValidatorAwareTrait
파일 보기 프로젝트 열기: cakephp/elastic-search 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_connection Cake\ElasticSearch\Datasource\Connection Connection instance
$_documentClass string The name of the class that represent a single document for this type
$_name string The name of the Elastic Search type this class represents
$embeds array Collection of Embedded sub documents this type has.
$schema Cake\ElasticSearch\Datasource\MappingSchema The mapping schema for this type.

공개 메소드들

메소드 설명
__construct ( array $config = [] ) Constructor
alias ( string $alias = null ) : string Get the alias for this Type.
callFinder ( string $type, Query $query, array $options = [] ) : Query Calls a finder method directly and applies it to the passed query, if no query is passed a new one will be created and returned
connection ( Connection $conn = null ) : Connection Returns the connection instance or sets a new one
defaultConnectionName ( ) : string The default connection name to inject when creating an instance.
delete ( Cake\Datasource\EntityInterface $entity, array $options = [] ) : boolean Delete a single entity.
deleteAll ( array $conditions ) : boolean Delete all matching records.
embedMany ( string $name, array $options = [] ) : void Mark a property in documents of this type as list of embedded sub-documents.
embedOne ( string $name, array $options = [] ) : void Mark a property in documents of this type as an embedded sub-document.
embedded ( ) : array Get the list of embedded documents this type has.
entityClass ( string $name = null ) : string Returns the class used to hydrate rows for this table or sets a new one
exists ( array $conditions ) : boolean Returns true if there is any record in this repository matching the specified conditions.
find ( string $type = 'all', array $options = [] ) : Query Creates a new Query for this repository and applies some defaults based on the type of search that was selected.
findAll ( Query $query, array $options = [] ) : Query Returns the query as passed
get ( string $primaryKey, array $options = [] ) : Document
getEventManager ( ) : Cake\Event\EventManager Get the event manager for this Table.
hasField ( string $field ) : boolean Check whether or not a field exists in the mapping.
implementedEvents ( ) : array Get the callbacks this Type is interested in.
initialize ( array $config ) : void Initialize a table instance. Called after the constructor.
marshaller ( ) : Marshaller Get a marshaller for this Type instance.
name ( string $name = null ) : string Returns the type name name or sets a new one
newEntities ( array $data, array $options = [] ) : array Create a list of entities + associated entities from an array.
newEntity ( array | null $data = null, array $options = [] ) : Cake\Datasource\EntityInterface Create a new entity + associated entities from an array.
patchEntities ( array | Traversable $entities, array $data, array $options = [] ) : array Merges each of the elements passed in $data into the entities found in $entities respecting the accessible fields configured on the entities.
patchEntity ( Cake\Datasource\EntityInterface $entity, array $data, array $options = [] ) : Cake\Datasource\EntityInterface Merges the passed $data into $entity respecting the accessible fields configured on the entity. Returns the same entity after being altered.
query ( ) : Query Creates a new Query instance for this repository
save ( Cake\Datasource\EntityInterface $entity, array $options = [] ) : Cake\Datasource\EntityInterface | boolean Persists an entity based on the fields that are marked as dirty and returns the same entity after a successful save or false in case of any error.
schema ( ) : array Get the mapping data from the index type.
table ( string $table = null ) : string Get/set the type/table name for this type.
updateAll ( array $fields, array $conditions ) : void Update all matching records.

메소드 상세

__construct() 공개 메소드

### Options - connection The Elastica instance. - name The name of the type. If this isn't set the name will be inferred from the class name. - eventManager Used to inject a specific eventmanager. At the end of the constructor the Model.initialize event will be triggered.
public __construct ( array $config = [] )
$config array The configuration options, see above.

alias() 공개 메소드

This method is just an alias of name().
public alias ( string $alias = null ) : string
$alias string The new type name
리턴 string

callFinder() 공개 메소드

Calls a finder method directly and applies it to the passed query, if no query is passed a new one will be created and returned
public callFinder ( string $type, Query $query, array $options = [] ) : Query
$type string name of the finder to be called
$query Query The query object to apply the finder options to
$options array List of options to pass to the finder
리턴 Query

connection() 공개 메소드

Returns the connection instance or sets a new one
public connection ( Connection $conn = null ) : Connection
$conn Cake\ElasticSearch\Datasource\Connection the new connection instance
리턴 Cake\ElasticSearch\Datasource\Connection

defaultConnectionName() 공개 정적인 메소드

The default connection name to inject when creating an instance.
public static defaultConnectionName ( ) : string
리턴 string

delete() 공개 메소드

Deletes an entity and possibly related associations from the database based on the 'dependent' option used when defining the association. Triggers the Model.beforeDelete and Model.afterDelete events.
public delete ( Cake\Datasource\EntityInterface $entity, array $options = [] ) : boolean
$entity Cake\Datasource\EntityInterface The entity to remove.
$options array The options for the delete.
리턴 boolean success

deleteAll() 공개 메소드

Deletes all records matching the provided conditions. This method will *not* trigger beforeDelete/afterDelete events. If you need those first load a collection of records and delete them.
또한 보기: RepositoryInterface::delete()
public deleteAll ( array $conditions ) : boolean
$conditions array An array of conditions, similar to those used with find()
리턴 boolean Success Returns true if one or more rows are effected.

embedMany() 공개 메소드

Embedded documents are converted into instances of the named document type. This allows you to attach entity level behavior to subsections of your documents. This method will make a list of embedded documents from the named property.
public embedMany ( string $name, array $options = [] ) : void
$name string The name of the property that contains the embedded document.
$options array The options for the embedded document.
리턴 void

embedOne() 공개 메소드

Embedded documents are converted into instances of the named document type. This allows you to attach entity level behavior to subsections of your documents.
public embedOne ( string $name, array $options = [] ) : void
$name string The name of the property that contains the embedded document.
$options array The options for the embedded document.
리턴 void

embedded() 공개 메소드

Get the list of embedded documents this type has.
public embedded ( ) : array
리턴 array

entityClass() 공개 메소드

Returns the class used to hydrate rows for this table or sets a new one
public entityClass ( string $name = null ) : string
$name string the name of the class to use
리턴 string

exists() 공개 메소드

Returns true if there is any record in this repository matching the specified conditions.
public exists ( array $conditions ) : boolean
$conditions array list of conditions to pass to the query
리턴 boolean

find() 공개 메소드

### Model.beforeFind event Each find() will trigger a Model.beforeFind event for all attached listeners. Any listener can set a valid result set using $query
public find ( string $type = 'all', array $options = [] ) : Query
$type string the type of query to perform
$options array An array that will be passed to Query::applyOptions
리턴 Query

findAll() 공개 메소드

Returns the query as passed
public findAll ( Query $query, array $options = [] ) : Query
$query Query An Elasticsearch query object
$options array An array of options to be used for query logic
리턴 Query

get() 공개 메소드

public get ( string $primaryKey, array $options = [] ) : Document
$primaryKey string The document's primary key
$options array An array of options
리턴 Document A new Elasticsearch document entity

getEventManager() 공개 메소드

Get the event manager for this Table.
public getEventManager ( ) : Cake\Event\EventManager
리턴 Cake\Event\EventManager

hasField() 공개 메소드

Check whether or not a field exists in the mapping.
public hasField ( string $field ) : boolean
$field string The field to check.
리턴 boolean

implementedEvents() 공개 메소드

By implementing the conventional methods a Type class is assumed to be interested in the related event. Override this method if you need to add non-conventional event listeners. Or if you want you table to listen to non-standard events. The conventional method map is: - Model.beforeMarshal => beforeMarshal - Model.beforeFind => beforeFind - Model.beforeSave => beforeSave - Model.afterSave => afterSave - Model.beforeDelete => beforeDelete - Model.afterDelete => afterDelete - Model.beforeRules => beforeRules - Model.afterRules => afterRules
public implementedEvents ( ) : array
리턴 array

initialize() 공개 메소드

You can use this method to define embedded documents, define validation and do any other initialization logic you need. public function initialize(array $config) { $this->embedMany('Comments'); }
public initialize ( array $config ) : void
$config array Configuration options passed to the constructor
리턴 void

marshaller() 공개 메소드

Get a marshaller for this Type instance.
public marshaller ( ) : Marshaller
리턴 Marshaller

name() 공개 메소드

Returns the type name name or sets a new one
public name ( string $name = null ) : string
$name string the new type name
리턴 string

newEntities() 공개 메소드

This is most useful when hydrating request data back into entities. For example, in your controller code: $articles = $this->Articles->newEntities($this->request->data()); The hydrated entities can then be iterated and saved.
public newEntities ( array $data, array $options = [] ) : array
$data array The data to build an entity with.
$options array A list of options for the objects hydration.
리턴 array An array of hydrated records.

newEntity() 공개 메소드

This is most useful when hydrating request data back into entities. For example, in your controller code: $article = $this->Articles->newEntity($this->request->data()); The hydrated entity will correctly do an insert/update based on the primary key data existing in the database when the entity is saved. Until the entity is saved, it will be a detached record.
public newEntity ( array | null $data = null, array $options = [] ) : Cake\Datasource\EntityInterface
$data array | null The data to build an entity with.
$options array A list of options for the object hydration.
리턴 Cake\Datasource\EntityInterface

patchEntities() 공개 메소드

Merging is done by matching the primary key in each of the elements in $data and $entities. This is most useful when editing a list of existing entities using request data: $article = $this->Articles->patchEntities($articles, $this->request->data());
public patchEntities ( array | Traversable $entities, array $data, array $options = [] ) : array
$entities array | Traversable the entities that will get the data merged in
$data array list of arrays to be merged into the entities
$options array A list of options for the objects hydration.
리턴 array

patchEntity() 공개 메소드

This is most useful when editing an existing entity using request data: $article = $this->Articles->patchEntity($article, $this->request->data());
public patchEntity ( Cake\Datasource\EntityInterface $entity, array $data, array $options = [] ) : Cake\Datasource\EntityInterface
$entity Cake\Datasource\EntityInterface the entity that will get the data merged in
$data array key value list of fields to be merged into the entity
$options array A list of options for the object hydration.
리턴 Cake\Datasource\EntityInterface

query() 공개 메소드

Creates a new Query instance for this repository
public query ( ) : Query
리턴 Query

save() 공개 메소드

Triggers the Model.beforeSave and Model.afterSave events. ## Options - checkRules Defaults to true. Check deletion rules before deleting the record.
public save ( Cake\Datasource\EntityInterface $entity, array $options = [] ) : Cake\Datasource\EntityInterface | boolean
$entity Cake\Datasource\EntityInterface The entity to be saved
$options array An array of options to be used for the event
리턴 Cake\Datasource\EntityInterface | boolean

schema() 공개 메소드

This will fetch the schema from ElasticSearch the first time this method is called.
public schema ( ) : array
리턴 array

table() 공개 메소드

Get/set the type/table name for this type.
public table ( string $table = null ) : string
$table string The 'table' name for this type.
리턴 string

updateAll() 공개 메소드

Sets the $fields to the provided values based on $conditions. This method will *not* trigger beforeSave/afterSave events. If you need those first load a collection of records and update them.
public updateAll ( array $fields, array $conditions ) : void
$fields array A hash of field => new value.
$conditions array An array of conditions, similar to those used with find()
리턴 void

프로퍼티 상세

$_connection 보호되어 있는 프로퍼티

Connection instance
protected Connection,Cake\ElasticSearch\Datasource $_connection
리턴 Cake\ElasticSearch\Datasource\Connection

$_documentClass 보호되어 있는 프로퍼티

The name of the class that represent a single document for this type
protected string $_documentClass
리턴 string

$_name 보호되어 있는 프로퍼티

The name of the Elastic Search type this class represents
protected string $_name
리턴 string

$embeds 보호되어 있는 프로퍼티

Collection of Embedded sub documents this type has.
protected array $embeds
리턴 array

$schema 보호되어 있는 프로퍼티

The mapping schema for this type.
protected MappingSchema,Cake\ElasticSearch\Datasource $schema
리턴 Cake\ElasticSearch\Datasource\MappingSchema