Wildcard Query
A wildcard query returns documents that contain terms matching a wildcard pattern.
Example
import (
es "github.com/elastic/go-elasticsearch/v8"
"github.com/sdqri/effdsl/v2"
wq "github.com/sdqri/effdsl/queries/wildcardquery"
)
query, err := effdsl.Define(
effdsl.WithQuery(
wq.WildcardQuery(
"user.id",
"ki*y",
wq.WithBoost(1.0),
wq.WithRewrite(wcq.ConstantScoreBlended),
),
),
)
res, err := es.Search(
es.Search.WithBody(strings.NewReader(query)),
)
Parameters
-
Field (string)
(Required, positional) The field you wish to search. This is a required parameter. -
Value (string)
(Required, positional) The wildcard pattern for terms you wish to find in the provided field. This is a required parameter. -
WithBoost (float64)
(Optional, Functional option) Floating point number used to decrease or increase the relevance scores of a query. Defaults to 1.0. -
WithCaseInsensitive (bool)
(Optional, Functional option) If true, the wildcard pattern is treated as case-insensitive. -
WithRewrite (Rewrite)
(Optional, Functional option) Method used to rewrite the query. For valid values and more information, see the rewrite parameter.
Additional Information
For more details on the wildcard query and its parameters, refer to the official Elasticsearch documentation on wildcard queries.