我使用Meilisearch作为laravel scout的驱动程序。
我的代码在控制器:
public function search(SearchInArticlesRequest $request)
{
$query = $request->s;
$articles = Article::search($query)
->where('article.status', '=', 'published')
->where('article.publish_date_time', '<=', Carbon::now()->toDateTimeString())
->paginate(20);
return response()->json([
'status' => 200,
'message' => 'articles_were_returned',
'entire' => [
'articles' => $articles
]
]);
}
MyArticle
model:
class Article extends Model
{
use HasFactory, Searchable;
protected $table = 'article';
public function toSearchableArray()
{
return $this->only(['id', 'title', 'body' , 'slug']);
}
}
我的composer.json
文件:
"require": {
"laravel/scout": "^9.2",
"meilisearch/meilisearch-php": "^0.18.3",
},
问题是:当调用上面几行提到的控制器方法时,出现以下错误:
Json deserialize error: unknown field filters, expected one of q, offset, limit, attributesToRetrieve, attributesToCrop, cropLength, attributesToHighlight, matches, filter, facetsDistribution at line 1 column 23
您正在尝试使用的SDK目前仅兼容稳定的v0.20和MeiliSearch的v0.21 RC