Property | Type | Description | |
---|---|---|---|
$Http | object | Holds HttpSocket Object | |
$columns | array | Elasticsearch column definition | |
$fullDebug | string | Prevents error from being thrown in CakeTestFixture | |
$useNestedTransactions | string | Prevents error from being thrown in CakeTestFixture |
Property | Type | Description | |
---|---|---|---|
$_document | array | The document for this transaction (for saving more than one model) | |
$_filterOps | string | Valid operators from DboSource to support | |
$_id | string | If we are in a transaction this is the id for the model we are indexing | |
$_listSources | boolean | Don't list sources by default, there's still some problems here | |
$_parent | string | Holding data for _parent. | |
$_queryLog | string | Query log | |
$_schema | array | Holds the mappings | |
$_transactionStarted | boolean | Track if we are in a transaction or not - allows saving multiple models to a document | |
$_type | string | If we are in a transaction this is the 'type' for the model indexing |
Method | Description | |
---|---|---|
__call ( string $method, array $arguments ) : mixed | Call HttpSocket methods | |
__construct ( array $config = [] ) | Constructor, call the parent and setup Http | |
addToDocument ( Model $Model, array $document = [] ) : boolean | Store a document to save later, merge it with existing model information for that document | |
afterParseConditions ( Model $Model, array $filters = [] ) : array | Perform this check after parseConditions has completed, since parseConditions is recursive we have to perform this check in a separate method (or use a static variable or whatever, but, I think this is cleaner) | |
allDocuments ( ) : array | Get all documents for this transaction | |
begin ( ) : true | Begin a transaction - allows saving of multiple models pseudo-automically through _bulk API, but it's main purpose is to allow saving associated model data and multiple models (saveMany/saveAssociated) | |
bulkIndex ( string $type = null, array $documents = [] ) : boolean | Bulk index a group of models | |
calculate ( Model $Model, $func, $params = null ) | ||
checkMapping ( Model $Model ) : boolean | Check to see if a mapping exists | |
commit ( ) : boolean | Save all models we have been storing | |
create ( Model $Model, array $fields = [], array $values = [] ) : mixed | If this operation is atomic then store the model data to be created on "commit" later, this allows for saving multiple models in one document through saveAll, saveMany, and saveAssociated. | |
createIndex ( $index, $alias = false, $settings = [] ) | ||
createSchema ( $Schema ) : void | Create schema, used in testing | |
currentDocument ( ) : array | Get the current document | |
currentModel ( Model &$Model ) : Model | Get/set the current model - called when requests are starting | |
delete ( Model $Model, array $conditions = null ) : boolean | Delete a record | |
describe ( $model ) : array | Describe a model based on it's mapping | |
dropIndex ( $index ) | ||
dropMapping ( Model $Model ) : boolean | Delete a mapping | |
dropSchema ( string $Schema ) : void | Drop a schema | |
execute ( $method = null, $type = null, $api = null, $data = [] ) | ||
filterResults ( array $results = [] ) : array | Filter results from a call, parsing out the records | |
fullTableName ( Model | string $model, boolean $quote = true, boolean $schema = true ) : string | Gets full table name including prefix | |
generateQuery ( Model $Model, array $queryData = [] ) : array | Generate an ElasticSearch query from Cake's ORM $queryData | |
geo ( $key, $operator, $value ) | ||
geoBoundary ( $field, array $boundaries ) : array | Creates filter for a geo boundary box | |
geoDistance ( $field, array $options ) : array | Creates filter for a geo distance search | |
geoDistanceRange ( $field, $minDistance ) : array | Creates filter for a geo distance range search | |
getColumnType ( Model $model, string $column ) : string | Returns the column type of a column in the model. | |
getLog ( ) : void | Get the query log - support for DebugKit Toolbar | |
getMapping ( ) : array | Get the entire index mapping | |
getType ( Model $Model ) : void | Get the useType if its set, otherwise use the table name | |
inTransaction ( ) : void | Check to see if we are in a transacion | |
index ( $type, $id = null, $document = [] ) | ||
insertMulti ( $type, array $fields, array $values, $refresh = true ) : void | Used by CakeTestFixture to insert many records. | |
isConnected ( ) : boolean | Returns true to signal that the source is connected to the datastore | |
listSources ( $data = NULL ) : array | List the types available for each index | |
logQuery ( string $method, string $uri, string $body, string $results = [] ) : void | Log a new query if debug is on | |
mapModel ( Model $Model, array $description = [], $alias = true ) : boolean | Map a model based on it's description from MySQL (or your own) | |
missing ( $key, $value ) | ||
name ( string $alias ) : string | Make Elastic play nice with Model::escapeField(); | |
parseConditions ( Model $Model, array $conditions = [] ) : array | Parse the 'conditions' key of a query from CakePHP's ORM | |
parseMapping ( array $mapping = [], $sourcesOnly = false ) : array | Parse an entire index mapping to create the schema for this datasource | |
parseOrder ( Model $Model, $query = [] ) | ||
parseQueryType ( $query ) | ||
query ( $method, $params, Model $Model ) | ||
range ( $key, $operator, $value ) | ||
read ( Model $Model, array $queryData = [], $recursive = NULL ) : mixed | Query ElasticSearch to retrieve records | |
reindex ( ElasticScroll $scroll, array $options = [] ) : void | Copies all documents from an index type to another | |
reset ( ) : void | Reset our transaction state, document, id, and type | |
resetSequence ( string $table, string $column ) : boolean | Reset a sequence based on the MAX() value of $column. Useful for resetting sequences after using insertMulti(). | |
rollback ( ) : void | Cancel this save operation/transaction | |
scan ( Model $model, integer $pageSize = 50, string $cursorTtl = '2m' ) : ElasticScroll | Returns an iterator with all results for an index type, the results order is maintained by Elastic search for $cursorTtl time in minutes. This function is commonly used for re-indexing a type when it's internal pproperty definition change. | |
term ( $key, $operator, $value ) | ||
truncate ( string $type, $refresh = true ) : void | Used by CakeTestFixture to truncate a type | |
typeToAlias ( $type ) : string | Convert a pluralized table name (test_models) to an alias (TestModel) | |
update ( Model $Model, $fields = [], $values = [], $conditions = NULL ) |
Method | Description | |
---|---|---|
_addLog ( string $data = [] ) : void | Added an item to the query log | |
_convertAttributes ( string $attr, string $val ) : string | Convert MySQL or CakePHP ORM field attributes into ElasticSearch compatible attributes | |
_findKey ( Model $Model, array $document = [] ) : mixed | Find the key for this document | |
_normalizeBoolFilter ( array $filter ) : array | Restructures bool filters so they have the propper formatting for Elastic Search | |
_parseDescription ( array $description = [], $Model = null ) : array | Recursive method to map a SQL-like model description into a ElasticSearch one | |
_parseKey ( Model $Model, string $key, mixed $value ) : array | Used to parse a key for ElasticSearch filters | |
_parseResponse ( CakeResponse $response ) : mixed | Parse the response from ElasticSearch, throwing errors if necessary | |
_setupTransaction ( Model $Model, array $document = [] ) : void | If we are in a new transaction, set _type and _id, if we are in an existing transaction then start a new document and set _id | |
_throwError ( string $info ) : void | Throw the right error | |
_uri ( array $config ) : array | Get the URI for a request |
public __construct ( array $config = [] ) | ||
$config | array |
protected _normalizeBoolFilter ( array $filter ) : array | ||
$filter | array | single bool filter created by _parseKey |
return | array |
protected _parseDescription ( array $description = [], $Model = null ) : array | ||
$description | array | |
return | array | Array representing ES Mapping |
protected _parseResponse ( CakeResponse $response ) : mixed | ||
$response | CakeResponse | |
return | mixed | boolean true or false, or body of request as array |
protected _setupTransaction ( Model $Model, array $document = [] ) : void | ||
$Model | Model | |
$document | array | |
return | void |
protected _throwError ( string $info ) : void | ||
$info | string | |
return | void |
public addToDocument ( Model $Model, array $document = [] ) : boolean | ||
$Model | Model | |
$document | array | |
return | boolean | true |
public afterParseConditions ( Model $Model, array $filters = [] ) : array | ||
$Model | Model | |
$filters | array | |
return | array |
public allDocuments ( ) : array | ||
return | array | Array of documents keyed by their primary key |
public begin ( ) : true | ||
return | true |
public checkMapping ( Model $Model ) : boolean | ||
$Model | Model | |
return | boolean | true if it exists |
public createSchema ( $Schema ) : void | ||
return | void |
public currentDocument ( ) : array | ||
return | array | Document data |
public currentModel ( Model &$Model ) : Model | ||
$Model | Model | |
return | Model | the current model |
public dropMapping ( Model $Model ) : boolean | ||
$Model | Model | |
return | boolean | true on success |
public dropSchema ( string $Schema ) : void | ||
$Schema | string | |
return | void |
public filterResults ( array $results = [] ) : array | ||
$results | array | |
return | array | Array of results |
public fullTableName ( Model | string $model, boolean $quote = true, boolean $schema = true ) : string | ||
$model | Model | string | Either a Model object or a string table name. |
$quote | boolean | Whether you want the table name quoted. |
$schema | boolean | Whether you want the schema name included. |
return | string | Full quoted table name |
public generateQuery ( Model $Model, array $queryData = [] ) : array | ||
$Model | Model | |
$queryData | array | |
return | array | Array that can be converted to JSON for ElasticSearch |
public geoBoundary ( $field, array $boundaries ) : array | ||
$boundaries | array | |
return | array |
public geoDistance ( $field, array $options ) : array | ||
$options | array | |
return | array |
public geoDistanceRange ( $field, $minDistance ) : array | ||
return | array |
public getColumnType ( Model $model, string $column ) : string | ||
$model | Model | instance to be inspected |
$column | string | The name of the model column |
return | string | Column type |
public getMapping ( ) : array | ||
return | array | ES Mapping |
public inTransaction ( ) : void | ||
return | void |
public isConnected ( ) : boolean | ||
return | boolean | True |
public listSources ( $data = NULL ) : array | ||
return | array | Array of types - similar to tables in a DB |
public parseConditions ( Model $Model, array $conditions = [] ) : array | ||
$Model | Model | |
$conditions | array | |
return | array | Array of filters for ElasticSearch |
public parseMapping ( array $mapping = [], $sourcesOnly = false ) : array | ||
$mapping | array | |
return | array | CakePHP schema |
public reindex ( ElasticScroll $scroll, array $options = [] ) : void | ||
$scroll | ElasticScroll | Iterator with results to be copied, can be from another server. |
$options | array | Array with following options: - toIndex: Target index name. If none provided then default configured index for this datasource will be used leave blanck wehn oyu want to copy data from one server to the other using same index name. - toType: Type name to use for storing new documents in target index (required) - transform: A callback function that will get each document before it is stored in target index. useful for adding, removing or changing any data before it is saved. |
return | void |
public scan ( Model $model, integer $pageSize = 50, string $cursorTtl = '2m' ) : ElasticScroll | ||
$model | Model | The model intance to introspect to get the scrollable results |
$pageSize | integer | as results are iterated, how large should the page be when asking Elastic Searhc for results bigger numbers make fewer requests to ElasticSearch but consume more memory and take longer to process in php |
$cursorTtl | string | Time to keep cursor results cached in Elastic Seaach (Example: '10m' for ten minutes) |
return | ElasticScroll | result iterator with all entries for an index type. |
public typeToAlias ( $type ) : string | ||
return | string |
public update ( Model $Model, $fields = [], $values = [], $conditions = NULL ) | ||
$Model | Model |
protected array $_document | ||
return | array |
protected string $_filterOps | ||
return | string |
protected string $_id | ||
return | string |
protected bool $_listSources | ||
return | boolean |
protected bool $_transactionStarted | ||
return | boolean |
protected string $_type | ||
return | string |
public string $fullDebug | ||
return | string |
public string $useNestedTransactions | ||
return | string |