Skip to content

Support SearchRequest compatibility for Msearch body and ScriptSource#1138

Merged
l-trotta merged 1 commit into
mainfrom
shared-body-search-msearch
Jan 16, 2026
Merged

Support SearchRequest compatibility for Msearch body and ScriptSource#1138
l-trotta merged 1 commit into
mainfrom
shared-body-search-msearch

Conversation

@l-trotta

@l-trotta l-trotta commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #151.
Adds an overload to the setter for the body of Msearch and the template of ScriptSource, both of which require an instance of SearchRequestBody, by converting an instance of SearchRequest to SearchRequestBody.

Usage:

// Normal search request
SearchRequest searchRequest = SearchRequest.of(b -> b
    .size(10)
    .from(10)
    .query(q -> q
        .matchAll(m -> m)
    )
);

// Using it to build Msearch
MsearchRequest msearchRequestOverload = MsearchRequest.of(ms -> ms
    .searches(s -> s
        .header(h -> h.index("index"))
        .body(searchRequest)
    )
);

// Or script source
ScriptSource scriptSourceOverload = ScriptSource.of(s -> s
    .scriptTemplate(searchRequest)
);

@l-trotta
l-trotta merged commit cff15cd into main Jan 16, 2026
14 checks passed
@l-trotta
l-trotta deleted the shared-body-search-msearch branch January 16, 2026 14:59
l-trotta added a commit that referenced this pull request Jan 16, 2026
#1138) (#1140)

Co-authored-by: Laura Trotta <153528055+l-trotta@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

msearch compatibility

1 participant