无法连接,请检查您的Algolia应用ID laravel

我想使用本地产品在本地电子商务网站中使用Algolia进行搜索,但是不幸的是,我总是从十几个错误中找到“无法连接,请检查您的Algolia应用程序ID”的错误,而没有找到解决方案,因此我很好地配置了侦察员和环境,但错误仍然存​​在。

Product.php

<?php

namespace App;

use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    use Searchable;
/**
     * Searchable rules.
     *
     * @var array
     */
    protected $searchable = [
        /**
         * Columns and their priority in search results.
         * Columns with higher values are more important.
         * Columns with equal values have equal importance.
         *
         * @var array
         */
        'columns' => [
            'products.name' => 10,
            'products.details' => 5,
            'products.description' => 2,
        ],
    ];

scout.php

<?php

return [

    'driver' => env('SCOUT_DRIVER', 'algolia'),
    'prefix' => env('SCOUT_PREFIX', ''),
    'queue' => env('SCOUT_QUEUE', true),
    'chunk' => [
        'searchable' => 500,
        'unsearchable' => 500,
    ],
    'soft_delete' => false,
    'algolia' => [
        'id' => env('ALGOLIA_APP_ID', 'XXX4TC'),
        'secret' => env('ALGOLIA_SECRET', 'xxxxxxxxxxxxxxxxxxxx3102ab168'),
    ],
];

.env

ALGOLIA_APP_ID=xxxxxxxxx
ALGOLIA_SECRET=xxxxxxxxxxxxxxxxxxx
SCOUT_QUEUE=true

shopController.php

public function search(Request $request)
    {
        $request->validate([
            'query' => 'required|min:3',
        ]);

        $query = $request->input('query');
        $products = Product::search($query)->paginate(10);                       

        return view('search-results')->with('products', $products);
    }
评论