Select Git revision
time_series.go
-
Jan Semmelink authoredJan Semmelink authored
opensearch_types.go 6.46 KiB
package search
import "time"
//Mapping configures an index in OpenSearch
type Settings struct {
Index *SettingsIndex `json:"index,omitempty"`
}
type SettingsIndex struct {
NumberOfShards int `json:"number_of_shards,omitempty"`
NumberOfReplicas int `json:"number_of_replicas,omitempty"`
}
type Mappings struct {
Properties map[string]MappingProperty `json:"properties,omitempty"`
}
type MappingProperty struct {
Type string `json:"type,omitempty"` //empty for sub-structs described with properties
Enabled bool `json:"enabled,omitempty"`
Fields map[string]MappingFieldProperties `json:"fields,omitempty"`
Properties map[string]MappingProperty `json:"properties,omitempty"`
//Index bool `json:"index,omitempty"` //set true to make text field searchable
}
type MappingFieldProperties struct {
Keyword *MappingKeyword `json:"keyword"`
}
type MappingKeyword struct {
Type string `json:"type"` //="keyword"
IgnoreAbove int `json:"ignore_above"` //e.g. 256
}
type SearchRequestBody struct {
Size int64 `json:"size,omitempty"`
Query Query `json:"query"`
}
type Query struct {
//one of:
Match *QueryNameValue `json:"match,omitempty" doc:"<field>:<value>"`
Term *QueryNameValue `json:"term,omitempty"`
Range *QueryRange `json:"range,omitempty"`
MultiMatch *QueryMultiMatch `json:"multi_match,omitempty"`
Bool *QueryBool `json:"bool,omitempty"`
QueryString *QueryString `json:"query_string,omitempty"`
}
type QueryMultiMatch struct {
Query string `json:"query" doc:"Full value match search in selected fields"`
Fields []string `json:"fields,omitempty" doc:"List of fields"`
}
type QueryString struct {
Query string `json:"query" doc:"Text search with partial matches, using asterisk for optional or question mark for required wildcards before and/or after text"`
}
//https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
type QueryBool struct {
Must []Query `json:"must,omitempty" docs:"List of things that must appear in matching documents and will contribute to the score."`
Filter []Query `json:"filter,omitempty" doc:"List of things that must appear in matching documents. However unlike must the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching."`
Should []Query `json:"should,omitempty" doc:"List of things that should appear in the matching document."`
MustNot []Query `json:"must_not,omitempty" doc:"List of things that must not appear in the matching documents. Clauses are executed in filter context meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned."`
}
//<name>:<value> can be shorthanded to just a text value "...", but for sake of go type def, we always use an object meaning the same, allowing more options
//https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#query-dsl-match-query-short-ex
type QueryNameValue map[string]QueryValue