doujiyun0041 2015-09-05 02:42
浏览 54

Laravel 5.1 - laravel-lucene-search

I am trying to use https://github.com/nqxcode/laravel-lucene-search

My composer.json looks like this:

"require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "bestmomo/scafold": "dev-master",
        "laravel/cashier": "~5.0",
        "laravel/socialite": "*",
        "nqxcode/laravel-lucene-search": "2.1.*"
    },

The composer update worked just fine.

Then I updated my config/app.php by adding 'Search' => Nqxcode\LuceneSearch\Facade::class, to aliases array and Nqxcode\LuceneSearch\ServiceProvider::class, to providers array.

Then I got and updated the config/laravel-lucene-search.php as shown below:

<?php

return [
    /*
     |--------------------------------------------------------------------------
     | The configurations of search index.
     |--------------------------------------------------------------------------
     |
     | The "path" is the path to Lucene search index.
     |
     | The "models" is the list of the descriptions for models. Each description
     | must contains class of model and fields available for search indexing.
     |
     | For example, model's description can be like this:
     |
     |      namespace\ModelClass::class => [
     |          'fields' => [
     |              'name', 'description', // Fields for indexing.
     |          ]
     |      ]
     |
     */
    'index' => [

        'path' => storage_path('app') . '/lucene-search/index',

        'models' => [

            App\Question::class => [
                'fields' => [
                    'title', 'raw_body', // Fields for indexing.
                ]
            ],


        ],
    ],

    /*
     |--------------------------------------------------------------------------
     | ZendSearch token filters.
     |--------------------------------------------------------------------------
     |
     | The "filters" is the list of ZendSearch token filters classes. Each class
     | must implement the TokenFilterInterface interface. Stemming token filter
     | for english and russian words is enabled by default. To disable it remove
     | class 'Nqxcode\Stemming\TokenFilterEnRu' from token filters.
     |
     | The "stopwords" is the list of paths to files with stopwords. By default
     | english and russian stopwords are used.
     |
    */
    'analyzer' => [

        'filters' => [
            Nqxcode\Stemming\TokenFilterEnRu::class,
        ],

        'stopwords' => Nqxcode\LuceneSearch\Analyzer\Stopwords\Files::get(),
    ],
];

Finally, I updated my Question Model as shown below:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Nqxcode\LuceneSearch\Model\Searchable;

class Question extends Model implements Searchable
{

    /**
     * Is the model available for searching?
     */
    public function isSearchable()
    {
        return $this->publish;
    }


    /**
     * The database table that the Model uses
     * @var string
     */
    protected $table = "questions";

    /**
     * The fields that are mass assignable
     * @var array
     */
    protected $fillable = ['title','body','images','quality_score','deactivated','creator_id','reviewer_id'];

    /*
     * We have a calculated field (body alternate) that we want to access
     */
    protected $appends = ['simple_body','raw_body'];

    public function getRawBodyAttribute(){
        return $this->attributes['body'];
    }

I build the index from my terminal using search:rebuild -v and it completed successfully.

Now, I am trying to do a simple test and it fails on this line in my controller: $questions = Search::query('masses')->get();

The results I get are: enter image description here

Does anyone know what is going wrong? Directory permissions should be ok. I am able to use the laravel filesystem. For example: Storage::disk('local')->put('file.txt', 'Contents');

@nqxcode

Edit: I gave 777 permission to the storage directory and still the same error.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog