Skip to content

Commit 7ce32d9

Browse files
committed
update search method docs
1 parent cafab9c commit 7ce32d9

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

readme.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -631,22 +631,28 @@ Array
631631
##### Search the entire document
632632

633633
```php
634-
ES::type("my_type")->search("bar")->get();
634+
ES::type("my_type")->search("hello")->get();
635635

636636
# search with Boost = 2
637637

638-
ES::type("my_type")->search("bar", 2)->get();
638+
ES::type("my_type")->search("hello", 2)->get();
639+
640+
# search within specific fields with different weights
641+
642+
ES::type("my_type")->search("hello", function($search){
643+
$search->boost(2)->fields(["title" => 2, "content" => 1])
644+
})->get();
639645
```
640646

641647
##### Return only first record
642648

643649
```php
644-
ES::type("my_type")->search("bar")->first();
650+
ES::type("my_type")->search("hello")->first();
645651
```
646652

647653
##### Return only count
648654
```php
649-
ES::type("my_type")->search("bar")->count();
655+
ES::type("my_type")->search("hello")->count();
650656
```
651657

652658
##### Scan-and-Scroll queries
@@ -659,14 +665,14 @@ ES::type("my_type")->search("bar")->count();
659665
# from Elasticsearch until there are no more results left.
660666
# It’s a bit like a cursor in a traditional database
661667

662-
$documents = ES::type("my_type")->search("foo")
668+
$documents = ES::type("my_type")->search("hello")
663669
->scroll("2m")
664670
->take(1000)
665671
->get();
666672

667673
# Response will contain a hashed code `scroll_id` will be used to get the next result by running
668674

669-
$documents = ES::type("my_type")->search("foo")
675+
$documents = ES::type("my_type")->search("hello")
670676
->scroll("2m")
671677
->scrollID("DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAFMFlJQOEtTdnJIUklhcU1FX2VqS0EwZncAAAAAAAABSxZSUDhLU3ZySFJJYXFNRV9laktBMGZ3AAAAAAAAAU4WUlA4S1N2ckhSSWFxTUVfZWpLQTBmdwAAAAAAAAFPFlJQOEtTdnJIUklhcU1FX2VqS0EwZncAAAAAAAABTRZSUDhLU3ZySFJJYXFNRV9laktBMGZ3")
672678
->get();
@@ -683,7 +689,7 @@ ES::type("my_type")->scrollID("DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAFMFlJQOEtTdnJIUklhc
683689
##### Paginate results with 5 records per page
684690

685691
```php
686-
$documents = ES::type("my_type")->search("bar")->paginate(5);
692+
$documents = ES::type("my_type")->search("hello")->paginate(5);
687693

688694
# Getting pagination links
689695

@@ -721,13 +727,13 @@ $documents->url($page)
721727
##### Getting the query array without execution
722728

723729
```php
724-
ES::type("my_type")->search("foo")->where("views", ">", 150)->query();
730+
ES::type("my_type")->search("hello")->where("views", ">", 150)->query();
725731
```
726732

727733
##### Getting the original elasticsearch response
728734

729735
```php
730-
ES::type("my_type")->search("foo")->where("views", ">", 150)->response();
736+
ES::type("my_type")->search("hello")->where("views", ">", 150)->response();
731737
```
732738

733739
##### Ignoring bad HTTP response
@@ -741,19 +747,19 @@ ES::type("my_type")->ignore(404, 500)->id(5)->first();
741747
Package comes with a built-in caching layer based on laravel cache.
742748

743749
```php
744-
ES::type("my_type")->search("foo")->remember(10)->get();
750+
ES::type("my_type")->search("hello")->remember(10)->get();
745751

746752
# Specify a custom cache key
747753

748-
ES::type("my_type")->search("foo")->remember(10, "last_documents")->get();
754+
ES::type("my_type")->search("hello")->remember(10, "last_documents")->get();
749755

750756
# Caching using other available driver
751757

752-
ES::type("my_type")->search("foo")->cacheDriver("redis")->remember(10, "last_documents")->get();
758+
ES::type("my_type")->search("hello")->cacheDriver("redis")->remember(10, "last_documents")->get();
753759

754760
# Caching with cache key prefix
755761

756-
ES::type("my_type")->search("foo")->cacheDriver("redis")->cachePrefix("docs")->remember(10, "last_documents")->get();
762+
ES::type("my_type")->search("hello")->cacheDriver("redis")->cachePrefix("docs")->remember(10, "last_documents")->get();
757763
```
758764

759765
##### Executing elasticsearch raw queries

0 commit comments

Comments
 (0)