You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 31, 2018. It is now read-only.
[Algolia Search](https://www.algolia.com) is a hosted full-text, numerical, and faceted search engine capable of delivering realtime results from the first keystroke.
4
4
5
5
This PHP package integrates the Algolia Search API to the Laravel Eloquent ORM. It's based on the [algoliasearch-client-php](https://github.com/algolia/algoliasearch-client-php) package. PHP 5.5.9+ is supported.
6
6
@@ -10,40 +10,98 @@ This PHP package integrates the Algolia Search API to the Laravel Eloquent ORM.
10
10
11
11
**Note:** If you're using Laravel 4, checkout the [algoliasearch-laravel-4](https://github.com/algolia/algoliasearch-laravel-4) repository.
Laravel Algolia requires a connection configuration. To get started, you'll need to publish all vendor assets:
49
107
@@ -55,9 +113,12 @@ You can add the ```--provider="Vinkla\Algolia\AlgoliaServiceProvider"``` option
55
113
56
114
This will create a `config/algolia.php` file in your app that you can modify to set your configuration. Also, make sure you check for changes compared to the original config file after an upgrade.
57
115
58
-
## Quick Start
59
116
60
-
### Quick Start
117
+
# Quick Start
118
+
119
+
120
+
121
+
## Quick Start
61
122
62
123
The following code adds search capabilities to your `Contact` model creating a `Contact` index:
63
124
@@ -95,7 +156,7 @@ After setting up your model, you need to manually do the initial import of your
95
156
Contact::reindex();
96
157
```
97
158
98
-
###Ranking & Relevance
159
+
## Ranking & Relevance
99
160
100
161
We provide many ways to configure your index settings to tune the overall relevancy but the most important ones are the **searchable attributes** and the attributes reflecting the **record popularity**. You can configure them with the following code:
101
162
@@ -125,7 +186,7 @@ You can propagate (save) the settings to algolia using the `setSetting` method:
125
186
Contact::setSettings();
126
187
```
127
188
128
-
#####Synonyms
189
+
#### Synonyms
129
190
130
191
Synonyms are used to tell the engine about words or expressions that should be considered equal in regard to the textual relevance.
131
192
@@ -158,11 +219,11 @@ You can propagate (save) the settings to algolia using the `setSetting` method:
158
219
Contact::setSettings();
159
220
```
160
221
161
-
###Frontend Search (realtime experience)
222
+
## Frontend Search (realtime experience)
162
223
163
224
Traditional search implementations tend to have search logic and functionality on the backend. This made sense when the search experience consisted of a user entering a search query, executing that search, and then being redirected to a search result page.
164
225
165
-
Implementing search on the backend is no longer necessary. In fact, in most cases it is harmful to performance because of the extra network and processing latency. We highly recommend the usage of our [JavaScript API Client](https://github.com/algolia/algoliasearch-client-js) issuing all search requests directly from the end user's browser, mobile device, or client. It will reduce the overall search latency while offloading your servers at the same time.
226
+
Implementing search on the backend is no longer necessary. In fact, in most cases it is harmful to performance because of the extra network and processing latency. We highly recommend the usage of our [JavaScript API Client](https://github.com/algolia/algoliasearch-client-javascript) issuing all search requests directly from the end user's browser, mobile device, or client. It will reduce the overall search latency while offloading your servers at the same time.
You could also use the `search` method but it's not recommended to implement a instant/realtime search experience from the backend (having a frontend search gives a better user experience):
180
241
181
242
```php
182
243
Contact::search('jon doe');
183
244
```
184
245
185
-
## Options
186
246
187
-
### Auto-indexing & Asynchronism
247
+
# Options
248
+
249
+
250
+
251
+
## Auto-indexing & Asynchronism
188
252
189
253
Each time a record is saved; it will be - asynchronously - indexed. On the other hand, each time a record is destroyed, it will be - asynchronously - removed from the index.
190
254
@@ -250,7 +314,7 @@ Be careful those two methods are defined in AlgoliaEloquentTrait.
250
314
When putting those methods in a parent class they will be "erased" by AlgoliaEloquentTrait if used in a child class
251
315
(because of php inheritance)
252
316
253
-
###Custom Index Name
317
+
## Custom Index Name
254
318
255
319
By default, the index name will be the pluralized class name, e.g. "Contacts". You can customize the index name by using the `$indices` option:
256
320
@@ -265,7 +329,7 @@ class Contact extends Model
265
329
}
266
330
```
267
331
268
-
###Per-environment Indexes
332
+
## Per-environment Indexes
269
333
270
334
You can suffix the index name with the current App environment using the following option:
271
335
@@ -280,7 +344,7 @@ class Contact extends Model
280
344
}
281
345
```
282
346
283
-
###Custom `objectID`
347
+
## Custom `objectID`
284
348
285
349
By default, the `objectID` is based on your record's `keyName` (`id` by default). You can change this behavior specifying the `objectIdKey` option (be sure to use a uniq field).
286
350
@@ -295,7 +359,7 @@ class Contact extends Model
295
359
}
296
360
```
297
361
298
-
###Restrict Indexing to a Subset of Your Data
362
+
## Restrict Indexing to a Subset of Your Data
299
363
300
364
You can add constraints controlling if a record must be indexed by defining the `indexOnly()` method.
301
365
@@ -313,9 +377,12 @@ class Contact extends Model
313
377
}
314
378
```
315
379
316
-
## Relationships
317
380
318
-
### Relationships
381
+
# Relationships
382
+
383
+
384
+
385
+
## Relationships
319
386
320
387
By default the Algolia package will fetch the **loaded** relationships.
321
388
@@ -355,10 +422,11 @@ public function getAlgoliaRecord()
355
422
```
356
423
357
424
425
+
# Indexing
426
+
358
427
359
-
## Indexing
360
428
361
-
###Manual Indexing
429
+
## Manual Indexing
362
430
363
431
You can trigger indexing using the `pushToIndex` instance method.
To *safely* reindex all your records (index to a temporary index + move the temporary index to the current one atomically), use the `reindex` class method:
382
450
@@ -414,17 +482,20 @@ Contact::reindex(true, true, false, function ($entities)
414
482
});
415
483
```
416
484
417
-
###Clearing an Index
485
+
## Clearing an Index
418
486
419
487
To clear an index, use the `clearIndices` class method:
420
488
421
489
```ruby
422
490
Contact::clearIndices();
423
491
```
424
492
425
-
## Manage indices
426
493
427
-
### Primary/Replica
494
+
# Manage indices
495
+
496
+
497
+
498
+
## Primary/Replica
428
499
429
500
You can define replica indexes using the `$algolia_settings` variable:
430
501
@@ -472,7 +543,7 @@ To search using a replica use the following code:
0 commit comments