Trait' App / Elasticquent Trait'没找到laravel5.2和elasticsearch-2.3.2

时间:2016-05-14 16:06:10

标签: elasticsearch laravel-5.2

我想使用弹性搜索。我安装弹性搜索-2.3.2。并在composer.json中将此包添加到require

"fairholm/elasticquent": "1.0.*",

这是我的产品型号

    <?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Elasticquent\ElasticquentTrait;


class Product extends BaseModel
{
    use ElasticquentTrait;
    protected $primaryKey = 'id';
    protected $table = 'products';
    protected $fillable =array('name','id','title','description','image','price','category_id','brand_id','created_at_ip','updated_at_ip');

    protected $mappingProperties = array(
        'name' => [
            'type' => 'string',
            "analyzer" => "standard",
        ],
        'title' => [
            'type' => 'string',
            "analyzer" => "standard",
        ],
        'description' => [
            'type' => 'string',
            "analyzer" => "stop",
            "stopwords" => [","]
        ],
    );

}

我收到两个错误

Undefined namespace Elasticquent
Undefined class ElasticquentTrait

如何解决? 请任何人帮助我

1 个答案:

答案 0 :(得分:0)

您需要在文件顶部添加以下内容:

use Elasticquent\ElasticquentTrait;

否则类自动加载器正在查找当前命名空间中的特征。