@@ -19,6 +19,12 @@ class Query
19
19
*/
20
20
public $ connection ;
21
21
22
+ /**
23
+ * Ignored HTTP errors
24
+ * @var array
25
+ */
26
+ public $ ignores = [400 , 404 , 500 ];
27
+
22
28
/**
23
29
* Filter operators
24
30
* @var array
@@ -554,7 +560,9 @@ public function query()
554
560
555
561
"from " => $ this ->getSkip (),
556
562
557
- "size " => $ this ->getTake ()
563
+ "size " => $ this ->getTake (),
564
+
565
+ 'client ' => ['ignore ' => $ this ->ignores ]
558
566
559
567
];
560
568
@@ -718,7 +726,8 @@ public function insert($data, $_id = NULL)
718
726
"index " => $ this ->getIndex (),
719
727
"type " => $ this ->getType (),
720
728
"id " => $ this ->_id ,
721
- "body " => $ data
729
+ "body " => $ data ,
730
+ 'client ' => ['ignore ' => $ this ->ignores ]
722
731
];
723
732
724
733
return (object )$ this ->connection ->index ($ parameters );
@@ -772,7 +781,8 @@ public function update($data, $_id = NULL)
772
781
"index " => $ this ->getIndex (),
773
782
"type " => $ this ->getType (),
774
783
"id " => $ this ->_id ,
775
- "body " => ['doc ' => $ data ]
784
+ "body " => ['doc ' => $ data ],
785
+ 'client ' => ['ignore ' => $ this ->ignores ]
776
786
];
777
787
778
788
return (object )$ this ->connection ->update ($ parameters );
@@ -829,7 +839,8 @@ public function script($script, $params = [])
829
839
"inline " => $ script ,
830
840
"params " => $ params
831
841
]
832
- ]
842
+ ],
843
+ 'client ' => ['ignore ' => $ this ->ignores ]
833
844
];
834
845
835
846
return (object )$ this ->connection ->update ($ parameters );
@@ -852,14 +863,13 @@ public function delete($_id = NULL)
852
863
"index " => $ this ->getIndex (),
853
864
"type " => $ this ->getType (),
854
865
"id " => $ this ->_id ,
855
- 'client ' => ['ignore ' => [ 400 , 404 ] ]
866
+ 'client ' => ['ignore ' => $ this -> ignores ]
856
867
];
857
868
858
869
return (object )$ this ->connection ->delete ($ parameters );
859
870
860
871
}
861
872
862
-
863
873
/**
864
874
* Return the native connection to execute native query
865
875
* @return object
@@ -870,4 +880,66 @@ public function raw()
870
880
}
871
881
872
882
883
+ /**
884
+ * Create a new index
885
+ * @param $name
886
+ * @param bool $callback
887
+ * @return mixed
888
+ */
889
+ function createIndex ($ name , $ callback = false ){
890
+
891
+ $ index = new Index ($ name , $ callback );
892
+
893
+ $ index ->connection = $ this ->connection ;
894
+
895
+ return $ index ->create ();
896
+
897
+ }
898
+
899
+
900
+ /**
901
+ * Drop index
902
+ * @param $name
903
+ * @return mixed
904
+ */
905
+ function dropIndex ($ name ){
906
+
907
+ $ index = new Index ($ name );
908
+
909
+ $ index ->connection = $ this ->connection ;
910
+
911
+ return $ index ->drop ();
912
+
913
+ }
914
+
915
+
916
+ /**
917
+ * create a new index [alias to createIndex method]
918
+ * @param bool $callback
919
+ * @return mixed
920
+ */
921
+ function create ($ callback = false ){
922
+
923
+ $ index = new Index ($ this ->index , $ callback );
924
+
925
+ $ index ->connection = $ this ->connection ;
926
+
927
+ return $ index ->create ();
928
+
929
+ }
930
+
931
+ /**
932
+ * Drop index [alias to dropIndex method]
933
+ * @return mixed
934
+ */
935
+ function drop (){
936
+
937
+ $ index = new Index ($ this ->index );
938
+
939
+ $ index ->connection = $ this ->connection ;
940
+
941
+ return $ index ->drop ();
942
+
943
+ }
944
+
873
945
}
0 commit comments