Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*QueryGenerator)
Option is a function that configures a query generator.
func WithFieldMapper ¶
WithFieldMapper allows validating incoming field names, and mapping them to internally defined ones. This can be used to prevent users from requiring knowledge about implementation details. Example usage:
WithFieldMapper(func(name string) (string, error) {
if !allowedFields[name] {
return "", fmt.Errorf("field %s is not allowed", name)
}
if name == "release_time" {
return "time", nil
}
return name, nil
})
func WithFieldValueMapper ¶
WithFieldValueMapper allows mapping incoming values for a field, or returning an error on invalid values. Example usage:
WithFieldValueMapper(func(name, value string) (string, error) {
if name == "user_id" and !isValidUserID(value) {
return "", fmt.Errorf("user id %s is not allowed", value)
}
return fmt.Sprintf("uid_%s", value), nil
})
type QueryGenerator ¶
type QueryGenerator struct {
// contains filtered or unexported fields
}
func NewQueryGenerator ¶
func NewQueryGenerator(options ...Option) *QueryGenerator
func (*QueryGenerator) ConvertAST ¶
ConvertAST converts a KQL AST to an Elasticsearch query.
Click to show internal directories.
Click to hide internal directories.