Skip to content
This repository was archived by the owner on Jul 31, 2018. It is now read-only.

Commit a06a0d2

Browse files
committed
Prepare algolia.com's integration
1 parent 5b5465f commit a06a0d2

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

README.md

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
<!--NO_HTML-->
12
# Laravel Algolia Search
3+
<!--/NO_HTML-->
24

35
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.
46

57
[![Build Status](https://img.shields.io/travis/algolia/algoliasearch-laravel/master.svg?style=flat)](https://travis-ci.org/algolia/algoliasearch-laravel)
68
[![Latest Version](https://img.shields.io/github/release/algolia/algoliasearch-laravel.svg?style=flat)](https://github.com/algolia/algoliasearch-laravel/releases)
79
[![License](https://img.shields.io/packagist/l/algolia/algoliasearch-laravel.svg?style=flat)](https://packagist.org/packages/algolia/algoliasearch-laravel)
810

9-
# Laravel 4
11+
**Note:** If you're using Laravel 4, checkout the [algoliasearch-laravel-4](https://github.com/algolia/algoliasearch-laravel-4) repository.
1012

11-
Checkout the [algoliasearch-laravel-4](https://github.com/algolia/algoliasearch-laravel-4) repository
13+
<!--NO_HTML-->
1214

1315
## Table of Content
1416

@@ -21,7 +23,9 @@ Checkout the [algoliasearch-laravel-4](https://github.com/algolia/algoliasearch-
2123
7. [Master/Slave](#masterslave)
2224
8. [Target multiple indexes](#target-multiple-indexes)
2325

24-
## Install
26+
<!--/NO_HTML-->
27+
28+
# Install
2529

2630
Add `algolia/algoliasearch-laravel` to your `composer.json` file:
2731

@@ -35,7 +39,7 @@ Add the service provider to `config/app.php` in the `providers` array.
3539
AlgoliaSearch\Laravel\AlgoliaServiceProvider::class
3640
```
3741

38-
## Configuration
42+
# Configuration
3943

4044
Laravel Algolia requires a connection configuration. To get started, you'll need to publish all vendor assets:
4145

@@ -47,7 +51,7 @@ You can add the ```--provider="Vinkla\Algolia\AlgoliaServiceProvider"``` option
4751

4852
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.
4953

50-
## Quick Start
54+
# Quick Start
5155

5256
The following code adds search capabilities to your `Contact` model creating a `Contact` index:
5357

@@ -79,7 +83,7 @@ class Contact extends Model
7983
}
8084
```
8185

82-
#### Ranking & Relevance
86+
## Ranking & Relevance
8387

8488
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:
8589

@@ -109,7 +113,7 @@ You can propagate (save) the settings to algolia using the `setSetting` method:
109113
Contact::setSettings();
110114
```
111115

112-
#### Frontend Search (realtime experience)
116+
## Frontend Search (realtime experience)
113117

114118
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.
115119

@@ -125,17 +129,17 @@ index.search('something', function(success, hits) {
125129
}, { hitsPerPage: 10, page: 0 });
126130
```
127131

128-
#### Backend Search
132+
## Backend Search
129133

130134
You could also use the `search` method but it's not recommended to implement instant/realtime search experience:
131135

132136
```php
133137
Contact::search('jon doe');
134138
```
135139

136-
## Options
140+
# Options
137141

138-
#### Auto-indexing & Asynchronism
142+
## Auto-indexing & Asynchronism
139143

140144
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.
141145

@@ -166,7 +170,7 @@ for ($i = 0; $i < 10000; $i++) {
166170
Contact::reindex(); // Will use batch operations.
167171
```
168172

169-
#### Custom Index Name
173+
## Custom Index Name
170174

171175
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:
172176

@@ -181,7 +185,7 @@ class Contact extends Model
181185
}
182186
```
183187

184-
#### Per-environment Indexes
188+
## Per-environment Indexes
185189

186190
You can suffix the index name with the current App environment using the following option:
187191

@@ -196,7 +200,7 @@ class Contact extends Model
196200
}
197201
```
198202

199-
#### Custom `objectID`
203+
## Custom `objectID`
200204

201205
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).
202206

@@ -211,7 +215,7 @@ class Contact extends Model
211215
}
212216
```
213217

214-
#### Restrict Indexing to a Subset of Your Data
218+
## Restrict Indexing to a Subset of Your Data
215219

216220
You can add constraints controlling if a record must be indexed by defining the `indexOnly()` method.
217221

@@ -229,7 +233,7 @@ class Contact extends Model
229233
}
230234
```
231235

232-
### Relationships
236+
# Relationships
233237

234238
By default the Algolia package will fetch the **loaded** relationships.
235239

@@ -270,9 +274,9 @@ public function getAlgoliaRecord()
270274

271275

272276

273-
## Indexing
277+
# Indexing
274278

275-
#### Manual Indexing
279+
## Manual Indexing
276280

277281
You can trigger indexing using the `pushToIndex` instance method.
278282

@@ -281,15 +285,16 @@ $contact = Contact::firstOrCreate(['name' => 'Jean']);
281285
$contact->pushToIndex();
282286
```
283287

284-
#### Manual Removal
288+
## Manual Removal
285289

286290
And trigger the removing using the `removeFromIndex` instance method.
287291

288292
```php
289293
$contact = Contact::firstOrCreate(['name' => 'Jean']);
290294
$contact->removeFromIndex();
291295
```
292-
#### Reindexing
296+
297+
## Reindexing
293298

294299
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:
295300

@@ -303,15 +308,15 @@ To reindex all your records (in place, without deleting out-dated records):
303308
Contact::reindex(false);
304309
```
305310

306-
#### Clearing an Index
311+
## Clearing an Index
307312

308313
To clear an index, use the `clearIndices` class method:
309314

310315
```ruby
311316
Contact::clearIndices();
312317
```
313318

314-
## Master/Slave
319+
# Master/Slave
315320

316321
You can define slave indexes using the `$algolia_settings` variable:
317322

@@ -359,7 +364,7 @@ To search using a slave use the following code:
359364
Book::search('foo bar', ['index' => 'contacts_desc']);
360365
```
361366

362-
## Target Multiple Indexes
367+
# Target Multiple Indexes
363368

364369
You can index a record in several indexes using the <code>$indices</code> property:
365370

@@ -392,7 +397,7 @@ To search using an extra index, use the following code:
392397
Book::search('foo bar', ['index' => 'contacts_private']);
393398
```
394399

395-
## Eloquent compatibility
400+
# Eloquent compatibility
396401

397402
Doing :
398403

@@ -409,12 +414,13 @@ To make this query work with Algolia you need to do it like that:
409414
Ad::find($id)->update($attributes);
410415
```
411416

412-
413-
## Compatibility
417+
<!--NO_HTML-->
418+
# Compatibility
414419

415420
Compatible with 5.x applications
416421

417422
## License
418423

419424
Laravel Algolia Search is licensed under [The MIT License (MIT)](LICENSE).
420425

426+
<!--/NO_HTML-->

0 commit comments

Comments
 (0)