@@ -631,22 +631,28 @@ Array
631
631
##### Search the entire document
632
632
633
633
``` php
634
- ES::type("my_type")->search("bar ")->get();
634
+ ES::type("my_type")->search("hello ")->get();
635
635
636
636
# search with Boost = 2
637
637
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();
639
645
```
640
646
641
647
##### Return only first record
642
648
643
649
``` php
644
- ES::type("my_type")->search("bar ")->first();
650
+ ES::type("my_type")->search("hello ")->first();
645
651
```
646
652
647
653
##### Return only count
648
654
``` php
649
- ES::type("my_type")->search("bar ")->count();
655
+ ES::type("my_type")->search("hello ")->count();
650
656
```
651
657
652
658
##### Scan-and-Scroll queries
@@ -659,14 +665,14 @@ ES::type("my_type")->search("bar")->count();
659
665
# from Elasticsearch until there are no more results left.
660
666
# It’s a bit like a cursor in a traditional database
661
667
662
- $documents = ES::type("my_type")->search("foo ")
668
+ $documents = ES::type("my_type")->search("hello ")
663
669
->scroll("2m")
664
670
->take(1000)
665
671
->get();
666
672
667
673
# Response will contain a hashed code `scroll_id` will be used to get the next result by running
668
674
669
- $documents = ES::type("my_type")->search("foo ")
675
+ $documents = ES::type("my_type")->search("hello ")
670
676
->scroll("2m")
671
677
->scrollID("DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAFMFlJQOEtTdnJIUklhcU1FX2VqS0EwZncAAAAAAAABSxZSUDhLU3ZySFJJYXFNRV9laktBMGZ3AAAAAAAAAU4WUlA4S1N2ckhSSWFxTUVfZWpLQTBmdwAAAAAAAAFPFlJQOEtTdnJIUklhcU1FX2VqS0EwZncAAAAAAAABTRZSUDhLU3ZySFJJYXFNRV9laktBMGZ3")
672
678
->get();
@@ -683,7 +689,7 @@ ES::type("my_type")->scrollID("DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAFMFlJQOEtTdnJIUklhc
683
689
##### Paginate results with 5 records per page
684
690
685
691
``` php
686
- $documents = ES::type("my_type")->search("bar ")->paginate(5);
692
+ $documents = ES::type("my_type")->search("hello ")->paginate(5);
687
693
688
694
# Getting pagination links
689
695
@@ -721,13 +727,13 @@ $documents->url($page)
721
727
##### Getting the query array without execution
722
728
723
729
``` php
724
- ES::type("my_type")->search("foo ")->where("views", ">", 150)->query();
730
+ ES::type("my_type")->search("hello ")->where("views", ">", 150)->query();
725
731
```
726
732
727
733
##### Getting the original elasticsearch response
728
734
729
735
``` php
730
- ES::type("my_type")->search("foo ")->where("views", ">", 150)->response();
736
+ ES::type("my_type")->search("hello ")->where("views", ">", 150)->response();
731
737
```
732
738
733
739
##### Ignoring bad HTTP response
@@ -741,19 +747,19 @@ ES::type("my_type")->ignore(404, 500)->id(5)->first();
741
747
Package comes with a built-in caching layer based on laravel cache.
742
748
743
749
``` php
744
- ES::type("my_type")->search("foo ")->remember(10)->get();
750
+ ES::type("my_type")->search("hello ")->remember(10)->get();
745
751
746
752
# Specify a custom cache key
747
753
748
- ES::type("my_type")->search("foo ")->remember(10, "last_documents")->get();
754
+ ES::type("my_type")->search("hello ")->remember(10, "last_documents")->get();
749
755
750
756
# Caching using other available driver
751
757
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();
753
759
754
760
# Caching with cache key prefix
755
761
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();
757
763
```
758
764
759
765
##### Executing elasticsearch raw queries
0 commit comments