PHP code example of antsfree / mxusearch
1. Go to this page and download the library: Download antsfree/mxusearch library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
antsfree / mxusearch example snippets
php artisan vendor:publish --provider="Antsfree\Mxusearch\MxusearchProvider"
php artisan search:reset-ini
/**
* 多条件查询功能
*
* @param $keyword
* @param string $field
* @param array $other_field_value
* @param array $range
* @param int $limit
* @param int $page
* @param array $sorts
*
* @return array
*/
public function multiSearch($keyword, $field = '', array $other_field_value = [], array $range = [], $limit = 0, $page = 1, array $sorts = []);
$key = '我是关键词';
$field = 'title';
// 多条件
$other_field_value = [
'site_id' => 1,
'column_id' => 2,
'type' => 'article',
// ...
];
$range = [
[
'field' => 'publish_time',
'from' => '2017-10-18 12:07:26',
'to' => '2017-10-23 17:07:26',
],
// ...
];
// 分页控制
$limit = 10;
$page = 1;
// 排序条件(true 为正序, false 为倒序)
$sorts = [
'field_1' => true, // 根据 field_1 正序排序
'field_2' => false // 根据 field_2 倒序排序
];
// 调用服务
Mxusearch::multiSearch($key, $field, $other_field, $range, $limit, $page, $sorts);