Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting for allow_leading_wildcard to search #103

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions opensearchapi/api.search.go
Expand Up @@ -63,6 +63,7 @@ type SearchRequest struct {

AllowNoIndices *bool
AllowPartialSearchResults *bool
AllowLeadingWildcard *bool
Analyzer string
AnalyzeWildcard *bool
BatchedReduceSize *int
Expand Down Expand Up @@ -148,6 +149,10 @@ func (r SearchRequest) Do(ctx context.Context, transport Transport) (*Response,
params["allow_partial_search_results"] = strconv.FormatBool(*r.AllowPartialSearchResults)
}

if r.AllowLeadingWildcard != nil {
params["allow_leading_wildcard"] = strconv.FormatBool(*r.AllowLeadingWildcard)
}

if r.Analyzer != "" {
params["analyzer"] = r.Analyzer
}
Expand Down Expand Up @@ -431,6 +436,14 @@ func (f Search) WithAnalyzer(v string) func(*SearchRequest) {
}
}

// WithAllowLeadingWildcard - the wildcard characters * and ? are allowed as the first character of the query string.
//
func (f Search) WithAllowLeadingWildcard(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.AllowLeadingWildcard = &v
}
}

// WithAnalyzeWildcard - specify whether wildcard and prefix queries should be analyzed (default: false).
//
func (f Search) WithAnalyzeWildcard(v bool) func(*SearchRequest) {
Expand Down