Skip to content
This repository has been archived by the owner on Oct 9, 2018. It is now read-only.

ovr/phalcon-elasticsearch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phalcon + Elastic

How to use

Create your model

namespace Models;

use Ovr\Phalcon\Elastic\ModelTrait;

class Project extends Injectable
{
    use ModelTrait;
    
    protected static $index = 'phalconist';
    protected static $type = 'project';
    
    /**
     * @param int $limit
     * @return mixed
     */
    public static function myQuery($limit = 25)
    {
        $query = [
            'aggs' => [
                'types' => [
                    'terms' => [
                        'field' => 'composer.type',
                        'size' => $limit,
                    ],
                ]
            ]
        ];
        
        $resultSet = static::getStorage()->search($query);
        return static::toTags($resultSet->getAggregation('types')['buckets'], 'key', 'doc_count');
    }
}

Use

$result = Project::myQuery(25);

License

This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.

About

Easy way to use Elastic in Phalcon

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages