@@ -27,6 +27,57 @@ Update the Scout driver in config/scout.php.
2727'driver' => env('SCOUT_DRIVER', 'ehann-redisearch'),
2828```
2929
30+ ### Define Searchable Schema
31+
32+ Define the field types that will be used on indexing
33+
34+ ``` php
35+ <?php
36+
37+ namespace App;
38+
39+ use Laravel\Scout\Searchable;
40+ ...
41+ use Ehann\RediSearch\Fields\TextField;
42+ use Ehann\RediSearch\Fields\GeoField;
43+ use Ehann\RediSearch\Fields\NumericField;
44+ use Ehann\RediSearch\Fields\TagField;
45+ use Ehann\RediSearch\Fields\GeoLocation;
46+ ...
47+
48+ class User extends Model {
49+ use Searchable;
50+
51+ public function searchableAs()
52+ {
53+ return "user_index";
54+ }
55+
56+ public function toSearchableArray()
57+ {
58+ return [
59+ "name" => $this->name,
60+ "username" => $this->username,
61+ "location" => new GeoLocation(
62+ $this->longitude,
63+ $this->latitude
64+ )
65+ "age" => $this->age,
66+ ];
67+ }
68+
69+ public function searchableSchema()
70+ {
71+ return [
72+ "name" => TextField::class,
73+ "username" => TextField::class,
74+ "location" => GeoField::class,
75+ "age" => NumericField::class
76+ ];
77+ }
78+ }
79+ ```
80+
3081### Import a Model
3182
3283Import a "Product" model that is [ configured to be searchable] ( https://laravel.com/docs/5.6/scout#configuration ) :
@@ -47,7 +98,17 @@ Import models without an ID field (this should be rarely needed):
4798artisan ehann:redisearch:import App\\ Product --no-id
4899```
49100
50- ## What now?
101+ ### Query Filters
102+
103+ How To Query Filters? [ Filtering Tag Fields] ( http://www.ethanhann.com/redisearch-php/searching/#filtering-tag-fields )
51104
52- See the [ Laravel Scout] ( https://laravel.com/docs/5.6/scout ) documentation for additional information.
105+ ``` php
106+ App\User::search("Search Query", function($index){
107+ return $filter->geoFilter("location", 5.56475, 5.75516, 100)
108+ ->numericFilter('age', 18, 32)
109+ })->get()
110+ ```
111+
112+ ## What now?
53113
114+ See the [ Laravel Scout] ( https://laravel.com/docs/5.6/scout ) documentation for additional information.
0 commit comments