laravel-elasticsearch icon indicating copy to clipboard operation
laravel-elasticsearch copied to clipboard

Feature/unsafe queries / Bug Fix Losing Connection

Open UseTheFork opened this issue 1 year ago • 1 comments

This PR aims to add a new option to allow a developer to opt into using "unsafe_queries". Essentially It's supposed to skip mapping checks and avoid doing any elastic search calls Except for when getting database info.

This is mostly needed from a performance perspective.

I also am running into a weird issue where save and saveWithOutRefresh lose their connection and as a result throw an exception. I can't replicate it in tests just in my environment that uses a Cloud connection. As a result, I added safety measures to ensure a connection existed before building the bridge.

UseTheFork avatar Oct 09 '24 15:10 UseTheFork

Thanks @use-the-fork, will have a look here when I get a chance

pdphilip avatar Oct 10 '24 11:10 pdphilip

Hey @use-the-fork , thanks for putting this one together. It's been published in v4.5.0

Just note that I changed the option name from perform_unsafe_queries to bypass_map_validation. perform_unsafe_queries may be construed as being more dangerous than it is to new users.

'elasticsearch' => [
    ......
     'options' => [
        'bypass_map_validation' => env('ES_OPT_BYPASS_MAP_VALIDATION', false),
         .....
    ],
    .....
],

pdphilip avatar Oct 17 '24 21:10 pdphilip

@pdphilip yea that makes sence. Thanks for merging it in!

UseTheFork avatar Oct 18 '24 00:10 UseTheFork