@@ -27,6 +27,57 @@ Update the Scout driver in config/scout.php.
27
27
'driver' => env('SCOUT_DRIVER', 'ehann-redisearch'),
28
28
```
29
29
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
+
30
81
### Import a Model
31
82
32
83
Import 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):
47
98
artisan ehann:redisearch:import App\\ Product --no-id
48
99
```
49
100
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 )
51
104
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?
53
113
114
+ See the [ Laravel Scout] ( https://laravel.com/docs/5.6/scout ) documentation for additional information.
0 commit comments