Skip to content

Commit 9cb4732

Browse files
committed
add scan and scroll queries
2 parents 00fa586 + 6fdc2f2 commit 9cb4732

File tree

3 files changed

+108
-1
lines changed

3 files changed

+108
-1
lines changed

readme.md

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

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

6064
ES::create("my_index", function($index){
6165
66+
<<<<<<< HEAD
6267
$index->shards(5)->replicas(1)->mappping([
68+
=======
69+
$index->shards(5)->replicas(1)->mapping([
70+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
6371
'my_type' => [
6472
'properties' => [
6573
'first_name' => [
@@ -182,7 +190,11 @@ Index and type names setted in query will override values the configuration file
182190

183191
##### Where not field exists
184192

193+
<<<<<<< HEAD
185194
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
186198
187199
##### Where not in clause
188200

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

217229
ES::search("bar")->count();
218230

231+
<<<<<<< HEAD
219232

220233
##### Scan-and-Scroll queries
221234

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

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

259274
>
260275
276+
<<<<<<< HEAD
261277
##### Ignoring bad HTTP response
262278
263279
$documents = ES::ignore(404, 500)->_id(5)->first();
264280

265281

266282
>
267283
284+
=======
285+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
268286
##### Executing elasticsearch raw queries
269287

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

396414
`Good luck`
397415

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

src/Index.php

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

9696
/**
97+
<<<<<<< HEAD
9798
* Ignore bad HTTP requests
9899
* @param array|int $code
99100
* @return $this
@@ -120,6 +121,8 @@ public function ignore($code)
120121
}
121122

122123
/**
124+
=======
125+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
123126
* Create a new index
124127
* @return mixed
125128
*/

src/Query.php

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

33
namespace Basemkhirat\Elasticsearch;
44

5+
<<<<<<< HEAD
56
use Illuminate\Pagination\LengthAwarePaginator;
67
use Illuminate\Support\Collection;
8+
=======
9+
use Illuminate\Support\Collection;
10+
use Illuminate\Pagination\LengthAwarePaginator;
11+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
712
use Illuminate\Support\Facades\Request;
813

914
/**
@@ -101,6 +106,7 @@ class Query
101106
protected $sort = [];
102107

103108
/**
109+
<<<<<<< HEAD
104110
* Query scroll time
105111
* @var string
106112
*/
@@ -119,6 +125,8 @@ class Query
119125
protected $search_type;
120126

121127
/**
128+
=======
129+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
122130
* Query limit
123131
* @var int
124132
*/
@@ -181,6 +189,7 @@ public function type($type)
181189
*/
182190
protected function getType()
183191
{
192+
<<<<<<< HEAD
184193

185194
return $this->type;
186195

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

246255
return $this->scroll;
247256

257+
=======
258+
return $this->type;
259+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
248260
}
249261

250262
/**
@@ -261,6 +273,7 @@ public function take($take = 10)
261273
}
262274

263275
/**
276+
<<<<<<< HEAD
264277
* Ignore bad HTTP response
265278
* @param array|int $code
266279
* @return $this
@@ -288,6 +301,9 @@ public function ignore($code)
288301

289302
/**
290303
* Get the query limit
304+
=======
305+
* get the query limit
306+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
291307
* @return int
292308
*/
293309
protected function getTake()
@@ -426,7 +442,11 @@ public function _id($_id = false)
426442
}
427443

428444
/**
445+
<<<<<<< HEAD
429446
* Set the query where clause
447+
=======
448+
* set the query where clause
449+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
430450
* @param $name
431451
* @param string $operator
432452
* @param null $value
@@ -483,7 +503,11 @@ public function where($name, $operator = "=", $value = NULL)
483503
}
484504

485505
/**
506+
<<<<<<< HEAD
486507
* Set the query inverse where clause
508+
=======
509+
* set the query inverse where clause
510+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
487511
* @param $name
488512
* @param string $operator
489513
* @param null $value
@@ -535,7 +559,11 @@ public function whereNot($name, $operator = "=", $value = NULL)
535559
}
536560

537561
/**
562+
<<<<<<< HEAD
538563
* Set the query where between clause
564+
=======
565+
* set the query where between clause
566+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
539567
* @param $name
540568
* @param $first_value
541569
* @param $last_value
@@ -551,7 +579,11 @@ public function whereBetween($name, $first_value, $last_value)
551579
}
552580

553581
/**
582+
<<<<<<< HEAD
554583
* Set the query where not between clause
584+
=======
585+
* set the query where not between clause
586+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
555587
* @param $name
556588
* @param $first_value
557589
* @param $last_value
@@ -567,7 +599,11 @@ public function whereNotBetween($name, $first_value, $last_value)
567599
}
568600

569601
/**
602+
<<<<<<< HEAD
570603
* Set the query where in clause
604+
=======
605+
* set the query where in clause
606+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
571607
* @param $name
572608
* @param array $value
573609
* @return $this
@@ -587,7 +623,11 @@ public function whereIn($name, $value = [])
587623
}
588624

589625
/**
626+
<<<<<<< HEAD
590627
* Set the query where not in clause
628+
=======
629+
* set the query where not in clause
630+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
591631
* @param $name
592632
* @param array $value
593633
* @return $this
@@ -608,7 +648,11 @@ public function whereNotIn($name, $value = [])
608648

609649

610650
/**
651+
<<<<<<< HEAD
611652
* Set the query where exists clause
653+
=======
654+
* set the query where exists clause
655+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
612656
* @param $name
613657
* @param bool $exists
614658
* @return $this
@@ -673,6 +717,7 @@ public function query()
673717

674718
];
675719

720+
<<<<<<< HEAD
676721
$search_type = $this->getSearchType();
677722

678723
if($search_type){
@@ -686,6 +731,8 @@ public function query()
686731
}
687732

688733

734+
=======
735+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
689736
return $query;
690737

691738
}
@@ -707,6 +754,7 @@ protected function validate($query)
707754
}
708755

709756

757+
<<<<<<< HEAD
710758

711759
/**
712760
* Clear scroll query id
@@ -750,6 +798,20 @@ public function get($scroll_id = NULL)
750798

751799
$result = $this->connection->search($query);
752800
}
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
753815

754816
return $this->getAll($result);
755817

@@ -810,8 +872,12 @@ protected function getAll($result = [])
810872
$new->max_score = $result["hits"]["max_score"];
811873
$new->took = $result["took"];
812874
$new->timed_out = $result["timed_out"];
875+
<<<<<<< HEAD
813876
$new->scroll_id = isset($result["_scroll_id"]) ? $result["_scroll_id"] : NULL;
814877
$new->shards = (object)$result["_shards"];
878+
=======
879+
$new->_shards = (object)$result["_shards"];
880+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
815881

816882
return $new;
817883
}
@@ -1038,8 +1104,12 @@ public function raw()
10381104
* @param bool $callback
10391105
* @return mixed
10401106
*/
1107+
<<<<<<< HEAD
10411108
function createIndex($name, $callback = false)
10421109
{
1110+
=======
1111+
function createIndex($name, $callback = false){
1112+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
10431113

10441114
$index = new Index($name, $callback);
10451115

@@ -1055,8 +1125,12 @@ function createIndex($name, $callback = false)
10551125
* @param $name
10561126
* @return mixed
10571127
*/
1128+
<<<<<<< HEAD
10581129
function dropIndex($name)
10591130
{
1131+
=======
1132+
function dropIndex($name){
1133+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
10601134

10611135
$index = new Index($name);
10621136

@@ -1072,8 +1146,12 @@ function dropIndex($name)
10721146
* @param bool $callback
10731147
* @return mixed
10741148
*/
1149+
<<<<<<< HEAD
10751150
function create($callback = false)
10761151
{
1152+
=======
1153+
function create($callback = false){
1154+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
10771155

10781156
$index = new Index($this->index, $callback);
10791157

@@ -1087,8 +1165,12 @@ function create($callback = false)
10871165
* Drop index [alias to dropIndex method]
10881166
* @return mixed
10891167
*/
1168+
<<<<<<< HEAD
10901169
function drop()
10911170
{
1171+
=======
1172+
function drop(){
1173+
>>>>>>> 6fdc2f25787d06ee7bcbcfcd82f36e727c753e44
10921174

10931175
$index = new Index($this->index);
10941176

0 commit comments

Comments
 (0)