Skip to content

Conversation

tharropoulos
Copy link
Collaborator

TLDR

Introduce Synonym Sets support in the Typesense client with full API integration, test coverage, and example usage.

Changes

Added Features:

  1. Client Support for Synonym Sets (Client.ts):

    • synonymSets() method added to the Client class with overloads for retrieving all sets or accessing individual sets by name.
    • Internally maintains _synonymSets and individualSynonymSets for caching and reuse.
  2. Synonym Set Management Classes:

    • SynonymSet.ts: Defines SynonymSet class to handle upsert, retrieve, and delete operations for a specific synonym set.
    • SynonymSets.ts: Manages operations for all synonym sets collectively.
  3. Collection Schema (Collection.ts, Collections.ts, Types.ts):

    • Collection creation and update schemas now support a synonym_sets array.
    • synonym_sets is also supported in search parameters for more refined query behavior.
  4. Version Detection Utility (utils.ts):

    • isV30OrAbove() function added to dynamically skip tests based on Typesense version (supports both nightly and stable v30+ builds).

Test Coverage:

  1. New Test Suite for Synonym Sets (SynonymSets.spec.ts):

    • Tests CRUD operations: upsert, retrieve (all and individual), and delete.
  2. Conditional Skipping for Existing Tests:

    • Tests for Analytics and Synonyms now use describe.skipIf(await isV30OrAbove(...)) to conditionally skip based on version compatibility.
  3. Test Refactoring:

    • Moved Typesense client initialization outside describe() blocks to reduce duplication.
    • Ensured all modified test files import the new version utility.

Documentation Updates:

  1. New TypeScript Example (synonymSets.ts):
    • Demonstrates full usage lifecycle:
      • Create a synonym set
      • Retrieve all/specific sets
      • Attach synonym sets to collections during creation and update
      • Delete a synonym set

PR Checklist

- implement SynonymSets class with retrieve method
- add SynonymItemSchema and SynonymSetSchema interfaces
- support for new /synonym_sets endpoint
- prepare for root-level synonym set management
…tions

- implement SynonymSet class with upsert, retrieve, and delete methods
- add SynonymSetDeleteSchema and SynonymSetRetrieveSchema interfaces
- add SynonymSets and SynonymSet imports and properties
- initialize _synonymSets and individualSynonymSets in constructor
- implement synonymSets() method with overloaded signatures
- implement isV30OrAbove function for client version detection
- support both nightly builds and versioned releases (v30+)
- enable conditional test execution based on Typesense version
…ed skipping

- extract typesense client initialization outside describe blocks
- add isV30OrAbove utility import to all affected test files
- implement describe.skipIf for conditional test execution
- skip analytics and synonym tests on Typesense v30+ and nightly builds
- implement test coverage for SynonymSets CRUD operations
- test upsert, retrieve, and delete methods for individual synonym sets
- include collection-level synonym set retrieval testing
- add proper setup and cleanup with beforeEach and afterEach hooks
- validate synonym set data structure and API responses
@jasonbosco jasonbosco merged commit 0367751 into typesense:master Aug 19, 2025
1 check passed
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.

2 participants