Skip to content

Conversation

@UseTheFork
Copy link
Collaborator

@UseTheFork UseTheFork commented Oct 9, 2024

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.

greg-assa and others added 7 commits October 9, 2024 09:54
… option

- Introduced `perform_unsafe_queries` and `insert_chunk_size` options in `Connection`.
- Updated `Query\Builder` to use configurable `insert_chunk_size` for bulk inserts.
- Adjusted test configuration to reflect new `insert_chunk_size` option.
… option

- Introduced `perform_unsafe_queries` and `insert_chunk_size` options in `Connection`.
- Updated `Query\Builder` to use configurable `insert_chunk_size` for bulk inserts.
- Adjusted test configuration to reflect new `insert_chunk_size` option.
- Eliminated the unused `rebuildConnection` method.
- Removed the redundant `rebuild` property from the Connection class.
- Adjusted `getClient` to build the connection if the client is missing.
- Deleted the call to `rebuildConnection` in the Bridge class.

Because who needs another rebuild when you can just health-check? 🔧✨
…ce check

- Introduced `LogicException` extending `LaravelElasticsearchException`.
- Created base `LaravelElasticsearchException` for custom exceptions.
- Updated `MissingOrderException` to extend `LaravelElasticsearchException`.
- Enhanced `Connection` to throw `LogicException` when method does not exist in `Bridge`.

Why throw shade when you can throw exceptions? 🌩️
@UseTheFork UseTheFork changed the title Feature/unsafe queries Feature/unsafe queries / Bug Fix Losing Connection Oct 9, 2024
@pdphilip
Copy link
Owner

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

- Properties with getters are inline with other connection based options
- Renamed perform_unsafe_queries to bypass_map_validation (sounds less ominous)
- Added bypass to other map check queries
@pdphilip pdphilip merged commit ca05aab into pdphilip:dev-main Oct 17, 2024
@pdphilip
Copy link
Owner

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),
         .....
    ],
    .....
],

@UseTheFork
Copy link
Collaborator Author

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

@UseTheFork UseTheFork deleted the feature/unsafe-queries branch May 7, 2025 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants