Skip to content

feat: add PerformUnion to MultiSearch to properly handle Union queries - #227

Merged
kishorenc merged 2 commits into
typesense:masterfrom
haydenhoang:fix-test
Jul 16, 2026
Merged

feat: add PerformUnion to MultiSearch to properly handle Union queries#227
kishorenc merged 2 commits into
typesense:masterfrom
haydenhoang:fix-test

Conversation

@haydenhoang

@haydenhoang haydenhoang commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Change Summary

This PR adds a dedicated PerformUnion method to MultiSearchInterface. When performing a multi-search with Union: true, the API returns a single SearchResult rather than an array of results. The existing Perform method attempts to parse this into a MultiSearchResult, which does not map correctly. This fixes #226.

Changes:

  • Added PerformUnion which forces Union: true on the request body and parses the response directly into api.SearchResult.
  • Added fail-fast validation to reject requests where a user explicitly passes Union: false to PerformUnion.
  • Added unit and integration tests.

Notes on OpenAPI Spec:

The last PR #216 adding support for union search added the hits field to MultiSearchResult in the local OpenAPI spec file but not in the shared Typesense API Spec. So a simple go generate ./... will override that PR's change.

I have chosen not to run go generate ./... in this PR, as pulling the latest spec introduces a lot of unrelated breaking changes to the Go client that should be handled in a separate major update.

PR Checklist

- This method unmarshal the body and return `SearchResult` instead of `MultiSearchResult`.
- Fixes typesense#226
@haydenhoang

Copy link
Copy Markdown
Contributor Author

@kishorenc

@kishorenc
kishorenc merged commit f55adb3 into typesense:master Jul 16, 2026
2 checks 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.

MultiSearch with union: true does not include metadata (found, page, etc)

3 participants