@@ -12,17 +12,17 @@ This package makes it easy to use native PostgreSQL Full Text Search capabilitie
12
12
## Contents
13
13
14
14
- [ Installation] ( #installation )
15
- - [ Scout 4.x] ( #scout-4x )
16
- - [ Scout 2.x, 3.x] ( #scout-2x-3x )
17
- - [ Scout 1.x] ( #scout-1x )
18
- - [ Laravel] ( #laravel )
19
- - [ Lumen] ( #lumen )
15
+ - [ Scout 4.x] ( #scout-4x )
16
+ - [ Scout 2.x, 3.x] ( #scout-2x-3x )
17
+ - [ Scout 1.x] ( #scout-1x )
18
+ - [ Laravel] ( #laravel )
19
+ - [ Lumen] ( #lumen )
20
20
- [ Configuration] ( #configuration )
21
- - [ Configuring the Engine] ( #configuring-the-engine )
22
- - [ Configuring PostgreSQL] ( #configuring-postgresql )
23
- - [ Prepare the Schema] ( #prepare-the-schema )
24
- - [ Configuring Searchable Data] ( #configuring-searchable-data )
25
- - [ Configuring the Model] ( #configuring-the-model )
21
+ - [ Configuring the Engine] ( #configuring-the-engine )
22
+ - [ Configuring PostgreSQL] ( #configuring-postgresql )
23
+ - [ Prepare the Schema] ( #prepare-the-schema )
24
+ - [ Configuring Searchable Data] ( #configuring-searchable-data )
25
+ - [ Configuring the Model] ( #configuring-the-model )
26
26
- [ Usage] ( #usage )
27
27
- [ Testing] ( #testing )
28
28
- [ Security] ( #security )
@@ -36,22 +36,26 @@ This package makes it easy to use native PostgreSQL Full Text Search capabilitie
36
36
You can install the package via composer:
37
37
38
38
### Scout 4.x (Laravel 5.4+)
39
+
39
40
``` bash
40
41
composer require pmatseykanets/laravel-scout-postgres
41
42
```
42
43
43
44
### Scout 2.x, 3.x
45
+
44
46
``` bash
45
47
composer require pmatseykanets/laravel-scout-postgres:1.0.0
46
48
```
47
49
48
50
### Scout 1.x
51
+
49
52
``` bash
50
53
composer require pmatseykanets/laravel-scout-postgres:0.2.1
51
54
```
52
55
53
56
54
57
### Laravel
58
+
55
59
If you're using Laravel < 5.5 or if you have package auto-discovery turned off you have to manually register the service provider:
56
60
57
61
``` php
@@ -63,6 +67,7 @@ If you're using Laravel < 5.5 or if you have package auto-discovery turned off y
63
67
```
64
68
65
69
### Lumen
70
+
66
71
Scout service provider uses ` config_path ` helper that is not included in the Lumen.
67
72
To fix this include the following snippet either directly in ` bootstrap.app ` or in your autoloaded helpers file i.e. ` app/helpers.php ` .
68
73
@@ -82,6 +87,7 @@ if (! function_exists('config_path')) {
82
87
```
83
88
84
89
Create the ` scout.php ` config file in ` app/config ` folder with the following contents
90
+
85
91
``` php
86
92
<?php
87
93
@@ -124,6 +130,10 @@ Specify the database connection that should be used to access indexed documents
124
130
// You can explicitly specify what PostgreSQL text search config to use by scout.
125
131
// Use \dF in psql to see all available configurations in your database.
126
132
'config' => 'english',
133
+ // You may set the default querying method
134
+ // Possible values: plainquery, phrasequery, tsquery
135
+ // plainquery is used if this option is omitted.
136
+ 'search_using' => 'tsquery'
127
137
],
128
138
...
129
139
```
@@ -154,13 +164,13 @@ class CreatePostsTable extends Migration
154
164
$table->integer('user_id');
155
165
$table->timestamps();
156
166
});
157
-
167
+
158
168
DB::statement('ALTER TABLE posts ADD searchable tsvector NULL');
159
169
DB::statement('CREATE INDEX posts_searchable_index ON posts USING GIN (searchable)');
160
170
// Or alternatively
161
171
// DB::statement('CREATE INDEX posts_searchable_index ON posts USING GIST (searchable)');
162
172
}
163
-
173
+
164
174
public function down()
165
175
{
166
176
Schema::drop('posts');
@@ -193,7 +203,7 @@ class Post extends Model
193
203
{
194
204
use Searchable;
195
205
196
- ...
206
+ // ...
197
207
public function searchableOptions()
198
208
{
199
209
return [
@@ -244,7 +254,9 @@ public function searchableAdditionalArray()
244
254
];
245
255
}
246
256
```
257
+
247
258
You may want to make your searchable column hidden so it's not standing in your way
259
+
248
260
``` php
249
261
protected $hidden = [
250
262
'searchable',
@@ -255,11 +267,10 @@ protected $hidden = [
255
267
256
268
Please see the [ official documentation] ( http://laravel.com/docs/master/scout ) on how to use Laravel Scout.
257
269
258
-
259
270
## Testing
260
271
261
272
``` bash
262
- $ composer test
273
+ composer test
263
274
```
264
275
265
276
## Security
0 commit comments