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
Copy file name to clipboardExpand all lines: README.md
+39-36Lines changed: 39 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,11 @@ Elasticsearch in laravel as if it were native to Laravel, meaning:
19
19
-[Eloquent style searching](#elasticsearching)
20
20
21
21
> # Alpha release notice
22
-
> This package is being released prematurely to an interested community of testers. It is not ready for production just yet only due to a lack of testing mileage. Once deemed stable, the plugin will move to V1. Elasticsearch is a deep topic on its own and there are many native features that have not yet been included. I built this because I needed it but this plugin is for everyone; submit issues (there's no way I could have found all the edge cases on my own) and feel free to submit pull requests.
22
+
> This package is being released prematurely to an interested community of testers. It is not ready for production just
23
+
> yet only due to a lack of testing mileage. Once deemed stable, the plugin will move to V1. Elasticsearch is a deep topic
24
+
> on its own and there are many native features that have not yet been included. I built this because I needed it but this
25
+
> plugin is for everyone; submit issues (there's no way I could have found all the edge cases on my own) and feel free to
-`$distance` is a string value of distance and distance-unit, see [https://www.elastic.co/guide/en/elasticsearch/reference/current/api-conventions.html#distance-units](distance units)
418
+
-`$distance` is a string value of distance and distance-unit,
419
+
see [https://www.elastic.co/guide/en/elasticsearch/reference/current/api-conventions.html#distance-units](distance units)
**Note:** the field **must be of type geo otherwise your [shards will fail](#error-all-shards-failed)**, make sure to set the geo field in your [migration](#migrations), ex:
425
+
**Note:** the field **must be of type geo otherwise your [shards will fail](#error-all-shards-failed)**, make sure to
426
+
set the geo field in your [migration](#migrations), ex:
@@ -436,8 +440,6 @@ Product::whereRegex('color','bl(ue)?(ack)?')->get(); //Returns blue or black
436
440
Product::whereRegex('color','bl...*')->get(); //Returns blue or black or blond or blush etc..
437
441
```
438
442
439
-
440
-
441
443
Saving Models
442
444
-------------
443
445
@@ -577,15 +579,15 @@ $product->forceDelete();
577
579
578
580
```
579
581
580
-
581
-
582
582
Elasticsearching
583
583
===============
584
584
585
585
The Search Query
586
586
----------------
587
587
588
-
The search query is different from the `where()->get()` methods as search is performed over all (or selected) fields in the index. Building a search query is easy and intuitive to seasoned Eloquenters with a slight twist; simply static call off your model with `term()`, chain your ORM clauses, then end your chain with `search()` to perform your search, ie:
588
+
The search query is different from the `where()->get()` methods as search is performed over all (or selected) fields in
589
+
the index. Building a search query is easy and intuitive to seasoned Eloquenters with a slight twist; simply static call
590
+
off your model with `term()`, chain your ORM clauses, then end your chain with `search()` to perform your search, ie:
In some cases you will need to split a model into different indices. There are limits to this to keep within reasonable Laravel ORM bounds, but if you keep the index prefix consistent then the plugin can manage the rest.
1219
+
In some cases you will need to split a model into different indices. There are limits to this to keep within reasonable
1220
+
Laravel ORM bounds, but if you keep the index prefix consistent then the plugin can manage the rest.
1219
1221
1220
1222
For example, let's imagine we're tracking page hits, the `PageHit.php` model could be
1221
1223
@@ -1240,9 +1242,10 @@ If you set a dynamic index you can read/search across all the indices that match
1240
1242
$pageHits = PageHit::where('page_id',1)->get();
1241
1243
```
1242
1244
1243
-
You will need to set the record's actual index when creating a new record, with `setIndex('value')`
1245
+
You will need to set the record's actual index when creating a new record, with `setIndex('value')`
1244
1246
1245
1247
Create example:
1248
+
1246
1249
```php
1247
1250
$pageHit = new PageHit
1248
1251
$pageHit->page_id = 4;
@@ -1253,11 +1256,11 @@ $pageHit->save();
1253
1256
```
1254
1257
1255
1258
Each eloquent model will have the current record's index embedded into it, to retrieve it simply call `getRecordIndex()`
0 commit comments