Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 181 | All time: 8,708 This week: 455![]() |
Version | License | PHP version | Categories | |||
torm-elastic 0.0.2 | GNU General Publi... | 5.5 | PHP 5, Databases, Searching, Design P..., T... |
This is a trait to insert ElasticSearch funcionality on TORM objects.
Change (or create, if needed) your Composer file to include it:
{
"require": {
"taq/torm-elastic": ">=0"
}
}
Just open your model and insert the trait, like:
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:
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.
Then we can search using something like:
$rtn = ElasticUser::elasticSearch("name", "john");
var_dump($rtn);
resulting in something like
array(2) {
'id' =>
string(1) "1"
'name' =>
string(12) "John Doe Jr."
}
When importing a new data collection, we can use the import
method, like:
User::elasticImport();
User:;elasticCount();
We can explicity update a document using:
$obj->updateElasticSearch();
We can explicity delete a document using:
$obj->deleteElasticSearch();
We can disable updating documents using
TORM\ElasticSearchConfigs::disabled(true);
and enable again sending false
on the same method.
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
.
If we want to avoid updating a document on the test enviroment, we can use
TORM\ElasticSearchConfigs::avoidOnTests(true);
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.