[英]Laravel scout algolia geosearch
I'm trying to make a request to my algolia index with geoSearch parameters. 我正在尝试使用geoSearch参数向我的阿尔戈利亚索引发送请求。 My query is working until I add the whereDate and all the where parameters after the search.
我的查询一直有效,直到在搜索之后添加whereDate和所有where参数。
Can you please tell me how to do the request properly ? 您能告诉我如何正确处理请求吗?
Thanks 谢谢
return Event::search('', function ($algolia, $query, $options) use ($lat, $lng, $radius){
$location = [
'aroundLatLng' => $lat.','.$lng,
'aroundRadius' => $radius * 1000,
];
$options = array_merge($options, $location);
return $algolia->search($query, $options);
})->whereDate('start_at', \Carbon\Carbon::parse($day))->where('end_at', '>=',
\Carbon\Carbon::parse($day))->orWhere('start_at', '<=', \Carbon\Carbon::parse($day))->where('end_at',
'>=', \Carbon\Carbon::parse($day))->orderBy('events.start_at')->orderBy('events.start_at')->get();
I think the best way would be to add the where statement in Algolia too. 我认为最好的方法就是在Algolia中添加where语句。 Laravel Scout only handle simple where clauses (only = to a numeric).
Laravel Scout仅处理简单的where子句(仅=表示数字)。
return Event::search('', function ($algolia, $query, $options) use ($lat, $lng, $radius){
$custom = [
'aroundLatLng' => $lat.','.$lng,
'aroundRadius' => $radius * 1000,
'filters' => 'start_at>12 AND end_at<16',
];
$options = array_merge($options, $custom);
return $algolia->search($query, $options);
})->get();
You can find the documentation related to filters here: https://www.algolia.com/doc/guides/searching/filtering/ 您可以在此处找到与过滤器相关的文档: https : //www.algolia.com/doc/guides/searching/filtering/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.