Package Data | |
---|---|
Maintainer Username: | xcalder |
Maintainer Contact: | liugj@126.com (liugj) |
Package Create Date: | 2018-07-25 |
Package Last Update: | 2018-07-25 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-23 03:12:33 |
Package Statistics | |
---|---|
Total Downloads: | 20 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Xunsearch Engine for Laravel Scout.
You can install the package via composer:
composer require liugj/lumen-xunsearch
You must add the Scout service provider and the package service provider in your bootstrap/app.php
line 80 config:
$app->register(Liugj\Xunsearch\XunsearchServiceProvider::class);
Publish the config file into your project by edit config/scout.php
line 62:
'xunsearch' => [
'index' => env('XUNSEARCH_INDEX_HOST', ''),
'search' => env('XUNSEARCH_SEARCH_HOST', ''),
'schema' => [
'brand_index'=>app()->basePath() .'/'. env('XUNSEARCH_SCHEMA_BRAND'),
]
],
Add Xunsearch settings into .env
file:
SCOUT_DRIVER=xunsearch
XUNSEARCH_INDEX_HOST=127.0.0.1:8383
XUNSEARCH_SEARCH_HOST=127.0.0.1:8384
XUNSEARCH_SCHEMA_BRAND=config/brand.ini
Now you can use Laravel Scout as described in the official documentation.
This enginge allows you to add more advanced "where" clauses.
$users = App\User::search('Star Trek')
->where('age', new \Liugj\Xunsearch\Operators\RangeOperator(30,50))->get();
$users = App\User::search('Star Trek')
->where('city', new \Liugj\Xunsearch\Operators\CollapseOperator($num = 10))->get();
$users = App\Users::search('Star Trek')
->where('**', new \Liugj\Xunsearch\Operators\FuzzyOperator($fuzzy = false))->get();
$users = App\Users::search('Star Trek')
->where('***', new \Liugj\Xunsearch\Operators\FacetsOperator(array('age','city')))->get();
$users = App\User::search('Star Trek')
->where('country', new \Liugj\Xunsearch\Operators\WeightOperator('US'))->get();
By default, the entire toArray form of a given model will be persisted to its search index. If you would like to customize the data that is synchronized to the search index, you may override the toSearchableArray method on the model:
<?php
namespace App;
use Liugj\Xunsearch\Searchable;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use Searchable;
/**
* Get the indexable data array for the model.
*
* @return array
*/
public function toSearchableArray()
{
$array = $this->toArray();
// Customize array...
return $array;
}
}
##Links
The MIT License (MIT).