yabhq / laravel-scout-mysql-driver

Laravel Scout MySQL Driver
MIT License
522 stars 113 forks source link

Please support for Laravel 5.5 #50

Closed eliyas5044 closed 6 years ago

eliyas5044 commented 7 years ago

Hello, Thanks for your great package. I installed it for laravel 5.4 and it worked fine, but when i tried to install in laravel 5.5, it won't installed. please support for laravel 5.5

cocochepeau commented 7 years ago

It's working for me with 5.5.

luyandasiko commented 7 years ago

Just jumping in here since I think my issue is pretty much related to the version of Lumen I am using which has 5.5.* version constraint. I have used this package with Laravel in one of our previous packages and now when I call the search method on the model all I get is an empty collection and no errors or anything.

I have removed the toSearchableArray so I can have my model inherit the definition that comes with the Searchable trait but in vein.

Collection {#103
  #items: []
}

The code snippet above shows what I am getting back and below are my settings:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Search Engine
    |--------------------------------------------------------------------------
    |
    | This option controls the default search connection that gets used while
    | using Laravel Scout. This connection is used when syncing all models
    | to the search service. You should adjust this based on your needs.
    |
    | Supported: "algolia", "null"
    |
    */

    'driver' => env('SCOUT_DRIVER', 'algolia'),

    /*
    |--------------------------------------------------------------------------
    | Index Prefix
    |--------------------------------------------------------------------------
    |
    | Here you may specify a prefix that will be applied to all search index
    | names used by Scout. This prefix may be useful if you have multiple
    | "tenants" or applications sharing the same search infrastructure.
    |
    */

    'prefix' => env('SCOUT_PREFIX', ''),

    /*
    |--------------------------------------------------------------------------
    | Queue Data Syncing
    |--------------------------------------------------------------------------
    |
    | This option allows you to control if the operations that sync your data
    | with your search engines are queued. When this is set to "true" then
    | all automatic data syncing will get queued for better performance.
    |
    */

    'queue' => env('SCOUT_QUEUE', false),

    /*
    |--------------------------------------------------------------------------
    | Chunk Sizes
    |--------------------------------------------------------------------------
    |
    | These options allow you to control the maximum chunk size when you are
    | mass importing data into the search engine. This allows you to fine
    | tune these chunk sizes based on the capabilites of your machines.
    |
    */

    'chunk' => [
        'searchable' => 500,
        'unsearchable' => 500,
    ],

    /*
    |--------------------------------------------------------------------------
    | Algolia Configuration
    |--------------------------------------------------------------------------
    |
    | Here you may configure your Algolia settings. Algolia is a cloud hosted
    | search engine which works great with Scout out of the box. Just plug
    | in your application ID and admin API key to get started searching.
    |
    */

    'algolia' => [
        'id' => env('ALGOLIA_APP_ID', ''),
        'secret' => env('ALGOLIA_SECRET', ''),
    ],

    'mysql' => [
        'mysql' => [
            'mode' => 'LIKE_EXPANDED',
            'model_directories' => [app_path()],
            'min_search_length' => 0,
            'min_fulltext_search_length' => 4,
            'min_fulltext_search_fallback' => 'LIKE',
            'query_expansion' => false
        ],
    ]
];

And my .env file is setup like this SCOUT_DRIVER=mysql.

What could I be missing in my Lumen configuration?

vinidotdev commented 7 years ago

I have the same problem, @luyandasiko

luyandasiko commented 7 years ago

@vinisouza I managed to solve my issue with just one line of code actually. AllI needed to do was to configure my scout configuration. Look at the code snippet below:

$app->confugure('scout');

You must bare in mind though that your config directory has a scout.php file with your settings. If, for some reason, you cannot have the library publish the config for you then you can just copy it into that directory.

Do let me know if that solves your problem, it solved mine.

Rgds

vinidotdev commented 7 years ago

It worked for me! Thanks a lot @luyandasiko

nivanmorgan commented 6 years ago

@vinisouza @luyandasiko how did you fix it again. where did you add $app->configure('scout');

luyandasiko commented 6 years ago

@vinisouza Please add that line of code within your APP_DIR/bootstrap/app.php file.

Thanks