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();
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.