Php 拉维尔-卢森搜索

Php 拉维尔-卢森搜索,php,laravel,laravel-4,lucene,composer-php,Php,Laravel,Laravel 4,Lucene,Composer Php,可能非常特定于此包。或者希望有人能帮忙 我正在使用这个作曲家软件包- 我已经按照安装说明进行了安装,我觉得 我已按如下方式设置配置: 'index' => [ 'path' => storage_path() . '/lucene-search/index', 'models' => [ // Add models descriptions here. 'Pack' => [

可能非常特定于此包。或者希望有人能帮忙

我正在使用这个作曲家软件包-

我已经按照安装说明进行了安装,我觉得

我已按如下方式设置配置:

'index' => [

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

        'models' => [
            // Add models descriptions here.
            'Pack' => [
                'fields' => [
                    'pack_title','pack_description',
                ]
            ]
        ],
    ],
在我的背包模型里面。我有以下几点

<?php

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

class Pack extends Model implements Searchable {

    public function isSearchable()
    {
        return $this->publish;
    }

    // Add your validation rules here
    public static $rules = [
        'pack_title' => 'required',
        'pack_description' => 'required',
        'primary_category_id' => 'required',
        'keystage'  => 'required',
        'pack_unit_price' => 'required'
    ];

    protected $primaryKey = "pack_id";

    // Don't forget to fill this array
    //protected $fillable = [];

    use SoftDeletingTrait;

    protected $dates = ['deleted_at'];
它只是感觉它没有在Packs模型中进行搜索。或者是不重要的

我是不是做错了什么。希望你们当中有人能帮忙


Cheers

设置配置时,必须运行php artisan search:rebuild-v以初始化搜索索引

之后,就可以执行搜索查询了。
如果索引未初始化,任何搜索查询的结果都将为空。

我不完全理解问题的本质。您在创建索引方面有问题吗?或者别的什么

每次创建或更新索引模型后,都必须更新搜索索引

您可以执行索引的全部或部分更新

要完全更新,请使用自述文件中的命令php artisan search:rebuild look Usage->artisan commands部分


注册必要的事件后,搜索索引的部分更新将起作用。查看自述文件中搜索索引部分的部分更新。

Hi Andrey@nqxcode我运行了搜索:重建,但也没有这样的运气。我已经在我的数据库中创建了一些项目,但它似乎不起作用。有趣的是,您提到的命令不在您的文档中。我还缺什么吗?
<?php

class SearchesController extends \BaseController {

    /**
     * Display a listing of the resource.
     * GET /search
     *
     * @return Response
     */
    public function index()
    {
        //
        $query = Search::query('A New Pack Title'); // search by 'name' field.

        $models = $query->get();

        var_dump(DB::getQueryLog());

        $count = $query->count();
    }
array(2) { [0]=> array(3) { ["query"]=> string(56) "select * from `categories` order by `category_order` asc" ["bindings"]=> array(0) { } ["time"]=> float(1.26) } [1]=> array(3) { ["query"]=> string(90) "select * from `packs` where `packs`.`deleted_at` is null and `packs`.`pack_id` = ? limit 1" ["bindings"]=> array(1) { [0]=> string(0) "" } ["time"]=> float(0.59) } }