@@ -77,6 +77,10 @@ class Connection extends BaseConnection
7777
7878 protected string $ connectionName ;
7979
80+ protected bool $ byPassMapValidation = false ;
81+
82+ protected int $ insertChunkSize = 1000 ;
83+
8084 /**
8185 * @var Query\Processor
8286 */
@@ -90,6 +94,7 @@ public function __construct(array $config)
9094 $ this ->config = $ config ;
9195
9296 $ this ->_sanitizeConfig ();
97+
9398 $ this ->_validateConnection ();
9499
95100 $ this ->setOptions ();
@@ -126,8 +131,34 @@ public function setOptions(): void
126131 : $ this ->config ['error_log_index ' ];
127132 }
128133
134+ if (! empty ($ this ->config ['options ' ]['bypass_map_validation ' ])) {
135+ $ this ->byPassMapValidation = $ this ->config ['options ' ]['bypass_map_validation ' ];
136+ }
137+
138+ if (! empty ($ this ->config ['options ' ]['insert_chunk_size ' ])) {
139+ $ this ->insertChunkSize = $ this ->config ['options ' ]['insert_chunk_size ' ];
140+ }
141+
142+ }
143+
144+ /** {@inheritdoc} */
145+ public function table ($ table , $ as = null )
146+ {
147+ $ query = new Query \Builder ($ this , new Query \Processor );
148+
149+ return $ query ->from ($ table );
150+ }
151+
152+ /** {@inheritdoc} */
153+ public function disconnect (): void
154+ {
155+ $ this ->client = null ;
129156 }
130157
158+ //----------------------------------------------------------------------
159+ // Getters
160+ //----------------------------------------------------------------------
161+
131162 /** {@inheritdoc} */
132163 public function getTablePrefix (): ?string
133164 {
@@ -176,21 +207,20 @@ public function getIndex(): string
176207 return $ this ->index ;
177208 }
178209
179- public function setIndex (string $ index ): string
210+ /** {@inheritdoc} */
211+ public function getDriverName (): string
180212 {
181- $ this ->index = $ this ->indexPrefix && ! str_contains ($ index , $ this ->indexPrefix .'_ ' )
182- ? $ this ->indexPrefix .'_ ' .$ index
183- : $ index ;
184-
185- return $ this ->getIndex ();
213+ return 'elasticsearch ' ;
186214 }
187215
188- /** {@inheritdoc} */
189- public function table ($ table , $ as = null )
216+ public function getClient (): ?Client
190217 {
191- $ query = new Query \Builder ($ this , new Query \Processor );
218+ return $ this ->client ;
219+ }
192220
193- return $ query ->from ($ table );
221+ public function getMaxSize (): int
222+ {
223+ return $ this ->maxSize ;
194224 }
195225
196226 /**
@@ -201,36 +231,55 @@ public function getSchemaBuilder(): Schema\Builder
201231 return new Schema \Builder ($ this );
202232 }
203233
204- /** {@inheritdoc} */
205- public function disconnect (): void
234+ public function getAllowIdSort (): bool
206235 {
207- $ this ->client = null ;
236+ return $ this ->allowIdSort ;
237+ }
238+
239+ public function getBypassMapValidation (): bool
240+ {
241+ return $ this ->byPassMapValidation ;
242+ }
243+
244+ public function getInsertChunkSize (): int
245+ {
246+ return $ this ->insertChunkSize ;
208247 }
209248
210249 /** {@inheritdoc} */
211- public function getDriverName (): string
250+ protected function getDefaultPostProcessor (): Query \ Processor
212251 {
213- return ' elasticsearch ' ;
252+ return new Query \ Processor ;
214253 }
215254
216- public function getClient (): ?Client
255+ /** {@inheritdoc} */
256+ protected function getDefaultQueryGrammar (): Query \Grammar
217257 {
218- return $ this -> client ;
258+ return new Query \ Grammar ;
219259 }
220260
221- public function getMaxSize (): int
261+ /** {@inheritdoc} */
262+ protected function getDefaultSchemaGrammar (): Schema \Grammar
222263 {
223- return $ this -> maxSize ;
264+ return new Schema \ Grammar ;
224265 }
225266
226- public function setMaxSize ($ value ): void
267+ //----------------------------------------------------------------------
268+ // Setters
269+ //----------------------------------------------------------------------
270+
271+ public function setIndex (string $ index ): string
227272 {
228- $ this ->maxSize = $ value ;
273+ $ this ->index = $ this ->indexPrefix && ! str_contains ($ index , $ this ->indexPrefix .'_ ' )
274+ ? $ this ->indexPrefix .'_ ' .$ index
275+ : $ index ;
276+
277+ return $ this ->getIndex ();
229278 }
230279
231- public function getAllowIdSort ( ): bool
280+ public function setMaxSize ( $ value ): void
232281 {
233- return $ this ->allowIdSort ;
282+ $ this ->maxSize = $ value ;
234283 }
235284
236285 public function __call ($ method , $ parameters )
@@ -245,33 +294,15 @@ public function __call($method, $parameters)
245294 }
246295 $ bridge = new Bridge ($ this );
247296
248- $ methodName = 'process ' . Str::studly ($ method );
297+ $ methodName = 'process ' . Str::studly ($ method );
249298
250299 if (! method_exists ($ bridge , $ methodName )) {
251- throw new LogicException ("{$ methodName } does not exist on the bridge. " );
300+ throw new LogicException ("{$ methodName } does not exist on the bridge. " );
252301 }
253302
254303 return $ bridge ->{$ methodName }(...$ parameters );
255304 }
256305
257- /** {@inheritdoc} */
258- protected function getDefaultPostProcessor (): Query \Processor
259- {
260- return new Query \Processor ;
261- }
262-
263- /** {@inheritdoc} */
264- protected function getDefaultQueryGrammar (): Query \Grammar
265- {
266- return new Query \Grammar ;
267- }
268-
269- /** {@inheritdoc} */
270- protected function getDefaultSchemaGrammar (): Schema \Grammar
271- {
272- return new Schema \Grammar ;
273- }
274-
275306 /**
276307 * Sanitizes the configuration array by merging it with a predefined array of default configuration settings.
277308 * This ensures that all required configuration keys exist, even if they are set to null or default values.
@@ -291,7 +322,7 @@ private function _sanitizeConfig(): void
291322 'api_id ' => null ,
292323 'index_prefix ' => '' ,
293324 'options ' => [
294- 'perform_unsafe_queries ' => false , // This skips the safety checks for Elastic Specific queries.
325+ 'bypass_map_validation ' => false , // This skips the safety checks for Elastic Specific queries.
295326 'insert_chunk_size ' => 1000 , // This is the maximum insert chunk size to use when bulk inserting
296327 'logging ' => false ,
297328 'allow_id_sort ' => false ,
0 commit comments