Skip to content

Commit abf8a1b

Browse files
committed
add scan and scroll queries
1 parent 9cb4732 commit abf8a1b

File tree

3 files changed

+1
-108
lines changed

3 files changed

+1
-108
lines changed

readme.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@
4040

4141
ES::index("my_index")->create(function($index){
4242
43-
<<<<<<< HEAD
4443
$index->shards(5)->replicas(1)->mappping([
45-
=======
46-
$index->shards(5)->replicas(1)->mapping([
47-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
4844
'my_type' => [
4945
'properties' => [
5046
'first_name' => [
@@ -63,11 +59,7 @@
6359

6460
ES::create("my_index", function($index){
6561
66-
<<<<<<< HEAD
6762
$index->shards(5)->replicas(1)->mappping([
68-
=======
69-
$index->shards(5)->replicas(1)->mapping([
70-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
7163
'my_type' => [
7264
'properties' => [
7365
'first_name' => [
@@ -190,11 +182,7 @@ Index and type names setted in query will override values the configuration file
190182

191183
##### Where not field exists
192184

193-
<<<<<<< HEAD
194185
ES::whereNot("hobbies", "exists", true)->get(); or ES::whereExists("hobbies", true)->get();
195-
=======
196-
ES::whereNot("hobbies", "exists", true)->get(); or ES::whereExists("hobbies", false)->get();
197-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
198186

199187
##### Where not in clause
200188

@@ -228,7 +216,6 @@ Index and type names setted in query will override values the configuration file
228216

229217
ES::search("bar")->count();
230218

231-
<<<<<<< HEAD
232219

233220
##### Scan-and-Scroll queries
234221

@@ -258,8 +245,6 @@ Index and type names setted in query will override values the configuration file
258245
ES::scrollID("DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAFMFlJQOEtTdnJIUklhcU1FX2VqS0EwZncAAAAAAAABSxZSUDhLU3ZySFJJYXFNRV9laktBMGZ3AAAAAAAAAU4WUlA4S1N2ckhSSWFxTUVfZWpLQTBmdwAAAAAAAAFPFlJQOEtTdnJIUklhcU1FX2VqS0EwZncAAAAAAAABTRZSUDhLU3ZySFJJYXFNRV9laktBMGZ3")
259246
->clear();
260247

261-
=======
262-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
263248
>
264249
265250
##### Paginate results with per_page = 5
@@ -273,16 +258,13 @@ Index and type names setted in query will override values the configuration file
273258

274259
>
275260
276-
<<<<<<< HEAD
277261
##### Ignoring bad HTTP response
278262
279263
$documents = ES::ignore(404, 500)->_id(5)->first();
280264

281265

282266
>
283267
284-
=======
285-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
286268
##### Executing elasticsearch raw queries
287269

288270
ES::raw()->search([
@@ -413,8 +395,4 @@ Index and type names setted in query will override values the configuration file
413395

414396
`Good luck`
415397

416-
<<<<<<< HEAD
417-
`Dont forget to send a feedback..`
418-
=======
419-
`Dont forget to send a feedback..`
420-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
398+
`Dont forget to send a feedback..`

src/Index.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public function replicas($replicas)
9494
}
9595

9696
/**
97-
<<<<<<< HEAD
9897
* Ignore bad HTTP requests
9998
* @param array|int $code
10099
* @return $this
@@ -121,8 +120,6 @@ public function ignore($code)
121120
}
122121

123122
/**
124-
=======
125-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
126123
* Create a new index
127124
* @return mixed
128125
*/

src/Query.php

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22

33
namespace Basemkhirat\Elasticsearch;
44

5-
<<<<<<< HEAD
65
use Illuminate\Pagination\LengthAwarePaginator;
76
use Illuminate\Support\Collection;
8-
=======
9-
use Illuminate\Support\Collection;
10-
use Illuminate\Pagination\LengthAwarePaginator;
11-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
127
use Illuminate\Support\Facades\Request;
138

149
/**
@@ -106,7 +101,6 @@ class Query
106101
protected $sort = [];
107102

108103
/**
109-
<<<<<<< HEAD
110104
* Query scroll time
111105
* @var string
112106
*/
@@ -125,8 +119,6 @@ class Query
125119
protected $search_type;
126120

127121
/**
128-
=======
129-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
130122
* Query limit
131123
* @var int
132124
*/
@@ -189,7 +181,6 @@ public function type($type)
189181
*/
190182
protected function getType()
191183
{
192-
<<<<<<< HEAD
193184

194185
return $this->type;
195186

@@ -254,9 +245,6 @@ public function getScroll()
254245

255246
return $this->scroll;
256247

257-
=======
258-
return $this->type;
259-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
260248
}
261249

262250
/**
@@ -273,7 +261,6 @@ public function take($take = 10)
273261
}
274262

275263
/**
276-
<<<<<<< HEAD
277264
* Ignore bad HTTP response
278265
* @param array|int $code
279266
* @return $this
@@ -301,9 +288,6 @@ public function ignore($code)
301288

302289
/**
303290
* Get the query limit
304-
=======
305-
* get the query limit
306-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
307291
* @return int
308292
*/
309293
protected function getTake()
@@ -442,11 +426,7 @@ public function _id($_id = false)
442426
}
443427

444428
/**
445-
<<<<<<< HEAD
446429
* Set the query where clause
447-
=======
448-
* set the query where clause
449-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
450430
* @param $name
451431
* @param string $operator
452432
* @param null $value
@@ -503,11 +483,7 @@ public function where($name, $operator = "=", $value = NULL)
503483
}
504484

505485
/**
506-
<<<<<<< HEAD
507486
* Set the query inverse where clause
508-
=======
509-
* set the query inverse where clause
510-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
511487
* @param $name
512488
* @param string $operator
513489
* @param null $value
@@ -559,11 +535,7 @@ public function whereNot($name, $operator = "=", $value = NULL)
559535
}
560536

561537
/**
562-
<<<<<<< HEAD
563538
* Set the query where between clause
564-
=======
565-
* set the query where between clause
566-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
567539
* @param $name
568540
* @param $first_value
569541
* @param $last_value
@@ -579,11 +551,7 @@ public function whereBetween($name, $first_value, $last_value)
579551
}
580552

581553
/**
582-
<<<<<<< HEAD
583554
* Set the query where not between clause
584-
=======
585-
* set the query where not between clause
586-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
587555
* @param $name
588556
* @param $first_value
589557
* @param $last_value
@@ -599,11 +567,7 @@ public function whereNotBetween($name, $first_value, $last_value)
599567
}
600568

601569
/**
602-
<<<<<<< HEAD
603570
* Set the query where in clause
604-
=======
605-
* set the query where in clause
606-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
607571
* @param $name
608572
* @param array $value
609573
* @return $this
@@ -623,11 +587,7 @@ public function whereIn($name, $value = [])
623587
}
624588

625589
/**
626-
<<<<<<< HEAD
627590
* Set the query where not in clause
628-
=======
629-
* set the query where not in clause
630-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
631591
* @param $name
632592
* @param array $value
633593
* @return $this
@@ -648,11 +608,7 @@ public function whereNotIn($name, $value = [])
648608

649609

650610
/**
651-
<<<<<<< HEAD
652611
* Set the query where exists clause
653-
=======
654-
* set the query where exists clause
655-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
656612
* @param $name
657613
* @param bool $exists
658614
* @return $this
@@ -717,7 +673,6 @@ public function query()
717673

718674
];
719675

720-
<<<<<<< HEAD
721676
$search_type = $this->getSearchType();
722677

723678
if($search_type){
@@ -731,8 +686,6 @@ public function query()
731686
}
732687

733688

734-
=======
735-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
736689
return $query;
737690

738691
}
@@ -754,7 +707,6 @@ protected function validate($query)
754707
}
755708

756709

757-
<<<<<<< HEAD
758710

759711
/**
760712
* Clear scroll query id
@@ -798,20 +750,6 @@ public function get($scroll_id = NULL)
798750

799751
$result = $this->connection->search($query);
800752
}
801-
=======
802-
/**
803-
* Get the collection of results
804-
* @return array|Collection
805-
*/
806-
public function get()
807-
{
808-
809-
$query = $this->query();
810-
811-
$this->validate($query);
812-
813-
$result = $this->connection->search($query);
814-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
815753

816754
return $this->getAll($result);
817755

@@ -872,12 +810,8 @@ protected function getAll($result = [])
872810
$new->max_score = $result["hits"]["max_score"];
873811
$new->took = $result["took"];
874812
$new->timed_out = $result["timed_out"];
875-
<<<<<<< HEAD
876813
$new->scroll_id = isset($result["_scroll_id"]) ? $result["_scroll_id"] : NULL;
877814
$new->shards = (object)$result["_shards"];
878-
=======
879-
$new->_shards = (object)$result["_shards"];
880-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
881815

882816
return $new;
883817
}
@@ -1104,12 +1038,8 @@ public function raw()
11041038
* @param bool $callback
11051039
* @return mixed
11061040
*/
1107-
<<<<<<< HEAD
11081041
function createIndex($name, $callback = false)
11091042
{
1110-
=======
1111-
function createIndex($name, $callback = false){
1112-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
11131043

11141044
$index = new Index($name, $callback);
11151045

@@ -1125,12 +1055,8 @@ function createIndex($name, $callback = false){
11251055
* @param $name
11261056
* @return mixed
11271057
*/
1128-
<<<<<<< HEAD
11291058
function dropIndex($name)
11301059
{
1131-
=======
1132-
function dropIndex($name){
1133-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
11341060

11351061
$index = new Index($name);
11361062

@@ -1146,12 +1072,8 @@ function dropIndex($name){
11461072
* @param bool $callback
11471073
* @return mixed
11481074
*/
1149-
<<<<<<< HEAD
11501075
function create($callback = false)
11511076
{
1152-
=======
1153-
function create($callback = false){
1154-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
11551077

11561078
$index = new Index($this->index, $callback);
11571079

@@ -1165,12 +1087,8 @@ function create($callback = false){
11651087
* Drop index [alias to dropIndex method]
11661088
* @return mixed
11671089
*/
1168-
<<<<<<< HEAD
11691090
function drop()
11701091
{
1171-
=======
1172-
function drop(){
1173-
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
11741092

11751093
$index = new Index($this->index);
11761094

0 commit comments

Comments
 (0)