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
@@ -13,9 +13,10 @@ Elasticsearch in laravel as if it were native to Laravel, meaning:
13
13
-[Soft Deletes](#soft-deletes)
14
14
-[Aggregations](#aggregation)
15
15
-[Migrations](#schema/index)
16
+
- ES features like [Geo Filtering](#geo) & [Regular Expressions](#regex-in-where)
16
17
17
18
- No need to write your own DSL queries ([unless you want to](#raw-dsl)!)
18
-
-This plugin is not a search wrapper for your existing models
19
+
-[Eloquent style searching](#elasticsearching)
19
20
20
21
> # Alpha release notice
21
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.
@@ -31,9 +32,9 @@ Elasticsearch in laravel as if it were native to Laravel, meaning:
-`$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)
**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:
Product::whereRegex('color','bl(ue)?(ack)?')->get(); //Returns blue or black
393
+
Product::whereRegex('color','bl...*')->get(); //Returns blue or black or blond or blush etc..
394
+
```
395
+
396
+
397
+
347
398
Saving Models
348
399
-------------
349
400
@@ -483,6 +534,131 @@ $product->forceDelete();
483
534
484
535
```
485
536
537
+
538
+
539
+
Elasticsearching
540
+
===============
541
+
542
+
The Search Query
543
+
----------------
544
+
545
+
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:
546
+
547
+
```php
548
+
MyModel::term('XYZ')->.........->search()
549
+
```
550
+
551
+
### 1.Term:
552
+
553
+
**1.1 Simple example**
554
+
555
+
- To search across all the fields in the **books** index for '**eric**' (case-insensitive if the default analyser is set),
556
+
- Results ordered by most relevant first (score in desc order)
557
+
558
+
```php
559
+
Book::term('Eric')->search();
560
+
```
561
+
562
+
**1.2 Multiple terms**
563
+
564
+
- To search across all the fields in the **books** index for: **eric OR (lean AND startup)**
565
+
-***Note**: You can't start a search query chain with and/or and you can't have subsequent chained terms without and/or - **ordering matters***
0 commit comments