2017 © Pedro Peláez
 

library torm-elastic

ElasticSearch integration for TORM

image

taq/torm-elastic

ElasticSearch integration for TORM

  • Saturday, July 11, 2015
  • by taq
  • Repository
  • 1 Watchers
  • 2 Stars
  • 39 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

TORM-elasticsearch

This is a trait to insert ElasticSearch funcionality on TORM objects., (*1)

Installation

Change (or create, if needed) your Composer file to include it:, (*2)

{
    "require": {
        "taq/torm-elastic": ">=0"
    }
}

Usage

Just open your model and insert the trait, like:, (*3)

class User extends TORM\Model {
    use TORM\ElasticSearch;
}
User::setElasticSearchIndex("myapp");

and, after every object saving, it will be send for ElasticSearch indexing, using some rules:, (*4)

  • Need to insert the trait using use TORM\ElasticSearch on the model;
  • Need to specify the app name using setElasticSearchIndex(). This will be the ElasticSearch index.
  • After inserting the trait, a new afterInitialize method will be added on the model. If the model already has a afterInitialize method, the TORM\ElasticSearch afterInitialize method must be called explicity on its end. This is because of the way PHP traits works.
  • If not specified, all the model attributes will be indexed. To define just some key attributes, we can use the setElasticSearchValues(<attributes>) method, sending an array with the attributes, like: User::setElasticSearchValues(["name"]); then only the name attribute will be indexed.

Searching

Then we can search using something like:, (*5)

$rtn = ElasticUser::elasticSearch("name", "john");
var_dump($rtn);

resulting in something like, (*6)

array(2) {
  'id' =>
  string(1) "1"
  'name' =>
  string(12) "John Doe Jr."
}

Importing

When importing a new data collection, we can use the import method, like:, (*7)

User::elasticImport();

Getting document count

User:;elasticCount();

Updating a document

We can explicity update a document using:, (*8)

$obj->updateElasticSearch();

Deleting a document

We can explicity delete a document using:, (*9)

$obj->deleteElasticSearch();

Disabling

We can disable updating documents using, (*10)

TORM\ElasticSearchConfigs::disabled(true);

and enable again sending false on the same method., (*11)

Testing

If using a TORM test enviroment (defined setting the enviroment var TORM_ENV to test), the index name will be automatically changed to <index_name>_test., (*12)

If we want to avoid updating a document on the test enviroment, we can use, (*13)

TORM\ElasticSearchConfigs::avoidOnTests(true);

The Versions

11/07 2015

dev-master

9999999-dev http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

11/07 2015

0.1.2

0.1.2.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

11/07 2015

0.1.1

0.1.1.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

10/07 2015

0.1.0

0.1.0.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

10/07 2015

0.0.9

0.0.9.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

10/07 2015

0.0.8

0.0.8.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

10/07 2015

0.0.7

0.0.7.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

10/07 2015

0.0.6

0.0.6.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

10/07 2015

0.0.5

0.0.5.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

10/07 2015

0.0.4

0.0.4.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

10/07 2015

0.0.3

0.0.3.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

10/07 2015

0.0.2

0.0.2.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord

10/07 2015

0.0.1

0.0.1.0 http://github.com/taq/torm-elastic

ElasticSearch integration for TORM

  Sources   Download

GPL

The Requires

 

orm database elasticsearch activerecord