typesense-java
typesense-java copied to clipboard
feat: add search presets support
Change Summary
This enhancement adds support for managing search presets in the Typesense Java client.
Rationale
By implementing search presets management, users can:
- Store and reuse common search configurations
- Maintain consistent search experiences across different parts of their application
- Easily manage search presets through a clean API interface
Changes
Added Features:
-
New Class
Presets.java:-
upsert(): Creates or updates a search preset with specified name -
retrieve(): Gets all available search presets - Base endpoint management for preset operations
-
-
New Class
Preset.java:-
retrieve(): Gets details of a specific search preset -
delete(): Removes a search preset - Individual preset management functionality
-
-
Client Integration in
Client.java:-
presets(): New method providing access to global preset operations -
presets(String presetId): Method for accessing individual preset operations - Added proper instance management for presets functionality
-
Code Changes:
-
In
Client.java:- Added presets management instance variables
- Implemented presets access methods
- Added initialization in constructor
Documentation Updates:
-
In
README.md:- Added code examples for all preset operations:
- Creating/updating a search preset
- Retrieving individual and all presets
- Deleting presets
- Clear usage examples with realistic search configurations
- Added code examples for all preset operations:
Test Coverage:
-
New Test Class
PresetsTest.java:- Comprehensive test coverage for all preset operations
- Tests for upsert, retrieve, retrieve all, and delete operations
- Proper setup and teardown handling
-
Updates to
Helper.java:- Added presets support in test utilities
- Implemented cleanup for presets in teardown
Context
This implementation aligns with Typesense's search presets API endpoints and provides a Java-friendly interface for managing search configurations. The changes follow existing patterns in the client library for consistency and ease of use. All operations are properly tested and documented to ensure reliability and maintainability.
PR Checklist
- [x] I have read and signed the Contributor License Agreement.