Skip to content

Commit

Permalink
doc: update go docs types
Browse files Browse the repository at this point in the history
  • Loading branch information
GokselKUCUKSAHIN committed Jan 5, 2025
1 parent b5701a0 commit d8a008a
Show file tree
Hide file tree
Showing 19 changed files with 278 additions and 274 deletions.
60 changes: 30 additions & 30 deletions es/aggregations.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type aggTermType Object
//
// Returns:
//
// An aggTermType object with the "field" set to the provided value.
// An es.aggTermType object with the "field" set to the provided value.
func AggTerm(field string) aggTermType {
return aggTermType{
"field": field,
Expand All @@ -31,7 +31,7 @@ func AggTerm(field string) aggTermType {
// Missing sets the "missing" value for an aggregation term.
//
// This method specifies a value to be used when the field is missing in documents.
// It updates the aggTermType object to handle missing values in the aggregation.
// It updates the es.aggTermType object to handle missing values in the aggregation.
//
// Example usage:
//
Expand All @@ -43,7 +43,7 @@ func AggTerm(field string) aggTermType {
//
// Returns:
//
// The updated aggTermType object with the "missing" field set to the specified value.
// The updated es.aggTermType object with the "missing" field set to the specified value.
func (aggTerm aggTermType) Missing(missing string) aggTermType {
aggTerm["missing"] = missing
return aggTerm
Expand All @@ -61,7 +61,7 @@ func (aggTerm aggTermType) Missing(missing string) aggTermType {
//
// Returns:
//
// An aggsType object with the "terms" field initialized.
// An es.aggsType object with the "terms" field initialized.
func AggTerms() aggsType {
return aggsType{
"terms": Object{},
Expand All @@ -80,7 +80,7 @@ func AggTerms() aggsType {
//
// Returns:
//
// An aggsType object with the "multi_terms" field initialized.
// An es.aggsType object with the "multi_terms" field initialized.
func AggMultiTerms() aggsType {
return aggsType{
"multi_terms": Object{},
Expand All @@ -99,7 +99,7 @@ func AggMultiTerms() aggsType {
//
// Returns:
//
// An aggsType object with the "nested" field initialized.
// An es.aggsType object with the "nested" field initialized.
func AggNested() aggsType {
return aggsType{
"nested": Object{},
Expand All @@ -117,7 +117,7 @@ func AggNested() aggsType {
//
// Returns:
//
// An aggsType object with the "max" field initialized.
// An es.aggsType object with the "max" field initialized.
func AggMax() aggsType {
return aggsType{
"max": Object{},
Expand All @@ -135,7 +135,7 @@ func AggMax() aggsType {
//
// Returns:
//
// An aggsType object with the "min" field initialized.
// An es.aggsType object with the "min" field initialized.
func AggMin() aggsType {
return aggsType{
"min": Object{},
Expand All @@ -153,7 +153,7 @@ func AggMin() aggsType {
//
// Returns:
//
// An aggsType object with the "avg" field initialized.
// An es.aggsType object with the "avg" field initialized.
func AggAvg() aggsType {
return aggsType{
"avg": Object{},
Expand All @@ -174,12 +174,12 @@ func AggAvg() aggsType {
//
// Returns:
//
// An aggsType object initialized with the provided custom aggregation.
// An es.aggsType object initialized with the provided custom aggregation.
func AggCustom(agg Object) aggsType {
return aggsType(agg)
}

// Aggs adds a nested aggregation to the aggsType object.
// Aggs adds a nested aggregation to the es.aggsType object.
//
// This method adds a nested aggregation under the "aggs" field with the given name.
//
Expand All @@ -195,7 +195,7 @@ func AggCustom(agg Object) aggsType {
//
// Returns:
//
// The updated aggsType object with the nested aggregation added.
// The updated es.aggsType object with the nested aggregation added.
func (agg aggsType) Aggs(name string, nestedAgg aggsType) aggsType {
aggs, ok := agg["aggs"].(Object)
if !ok {
Expand All @@ -206,9 +206,9 @@ func (agg aggsType) Aggs(name string, nestedAgg aggsType) aggsType {
return agg
}

// Field sets the "field" value in the aggsType object.
// Field sets the "field" value in the es.aggsType object.
//
// This method specifies the field to aggregate on in the aggsType object.
// This method specifies the field to aggregate on in the es.aggsType object.
//
// Example usage:
//
Expand All @@ -220,14 +220,14 @@ func (agg aggsType) Aggs(name string, nestedAgg aggsType) aggsType {
//
// Returns:
//
// The updated aggsType object with the "field" set to the specified value.
// The updated es.aggsType object with the "field" set to the specified value.
func (agg aggsType) Field(field string) aggsType {
return agg.putInTheField("field", field)
}

// Path sets the "path" value in the aggsType object.
// Path sets the "path" value in the es.aggsType object.
//
// This method specifies the nested path for the aggregation in the aggsType object.
// This method specifies the nested path for the aggregation in the es.aggsType object.
//
// Example usage:
//
Expand All @@ -239,12 +239,12 @@ func (agg aggsType) Field(field string) aggsType {
//
// Returns:
//
// The updated aggsType object with the "path" set to the specified value.
// The updated es.aggsType object with the "path" set to the specified value.
func (agg aggsType) Path(path string) aggsType {
return agg.putInTheField("path", path)
}

// Size sets the "size" value in the aggsType object.
// Size sets the "size" value in the es.aggsType object.
//
// This method specifies the number of terms to return in the aggregation result.
//
Expand All @@ -258,12 +258,12 @@ func (agg aggsType) Path(path string) aggsType {
//
// Returns:
//
// The updated aggsType object with the "size" field set to the specified value.
// The updated es.aggsType object with the "size" field set to the specified value.
func (agg aggsType) Size(size int) aggsType {
return agg.putInTheField("size", size)
}

// Order sets the "order" field in the aggsType object.
// Order sets the "order" field in the es.aggsType object.
//
// This method specifies the sorting order for the aggregation results.
//
Expand All @@ -278,7 +278,7 @@ func (agg aggsType) Size(size int) aggsType {
//
// Returns:
//
// The updated aggsType object with the "order" field set to the specified value.
// The updated es.aggsType object with the "order" field set to the specified value.
func (agg aggsType) Order(field string, order Order.Order) aggsType {
return agg.putInTheField("order",
Object{
Expand All @@ -287,7 +287,7 @@ func (agg aggsType) Order(field string, order Order.Order) aggsType {
)
}

// Include sets the "include" field in the aggsType object.
// Include sets the "include" field in the es.aggsType object.
//
// This method specifies a pattern to include in the aggregation results.
//
Expand All @@ -301,12 +301,12 @@ func (agg aggsType) Order(field string, order Order.Order) aggsType {
//
// Returns:
//
// The updated aggsType object with the "include" field set to the specified value.
// The updated es.aggsType object with the "include" field set to the specified value.
func (agg aggsType) Include(include string) aggsType {
return agg.putInTheField("include", include)
}

// Exclude sets the "exclude" field in the aggsType object.
// Exclude sets the "exclude" field in the es.aggsType object.
//
// This method specifies a pattern to exclude from the aggregation results.
//
Expand All @@ -320,14 +320,14 @@ func (agg aggsType) Include(include string) aggsType {
//
// Returns:
//
// The updated aggsType object with the "exclude" field set to the specified value.
// The updated es.aggsType object with the "exclude" field set to the specified value.
func (agg aggsType) Exclude(exclude string) aggsType {
return agg.putInTheField("exclude", exclude)
}

// Terms sets the "terms" field in the aggsType object.
//
// This method adds a list of aggregation terms to the "terms" field of the aggsType object.
// This method adds a list of aggregation terms to the "terms" field of the es.aggsType object.
// It allows specifying multiple term aggregations for the aggregation query.
//
// Example usage:
Expand All @@ -340,11 +340,11 @@ func (agg aggsType) Exclude(exclude string) aggsType {
// // agg now has the "terms" field containing the provided term aggregations.
//
// Parameters:
// - terms: A variadic list of aggTermType objects representing the term aggregations.
// - terms: A variadic list of es.aggTermType objects representing the term aggregations.
//
// Returns:
//
// The updated aggsType object with the "terms" field set to the provided term aggregations.
// The updated es.aggsType object with the "terms" field set to the provided term aggregations.
func (agg aggsType) Terms(terms ...aggTermType) aggsType {
return agg.putInTheField("terms", terms)
}
Expand All @@ -362,7 +362,7 @@ func (agg aggsType) Terms(terms ...aggTermType) aggsType {
//
// Parameters:
// - name: The name to associate with the nested aggregation.
// - agg: The aggsType object representing the nested aggregation.
// - agg: The es.aggsType object representing the nested aggregation.
//
// Returns:
//
Expand Down
40 changes: 20 additions & 20 deletions es/base_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type sortType Object
//
// Returns:
//
// An Object containing the "query" field with the processed query clause.
// An es.Object containing the "query" field with the processed query clause.
func NewQuery(queryClause any) Object {
if field, ok := correctType(queryClause); ok {
return Object{
Expand Down Expand Up @@ -54,7 +54,7 @@ func NewQuery(queryClause any) Object {
//
// Returns:
//
// The updated Object with the "track_total_hits" parameter set.
// The updated es.Object with the "track_total_hits" parameter set.
func (o Object) TrackTotalHits(value bool) Object {
o["track_total_hits"] = value
return o
Expand All @@ -78,7 +78,7 @@ func (o Object) TrackTotalHits(value bool) Object {
//
// Returns:
//
// The updated Object with the "size" parameter set.
// The updated es.Object with the "size" parameter set.
func (o Object) Size(size int) Object {
o["size"] = size
return o
Expand All @@ -102,7 +102,7 @@ func (o Object) Size(size int) Object {
//
// Returns:
//
// The updated Object with the "from" parameter set.
// The updated es.Object with the "from" parameter set.
func (o Object) From(from int) Object {
o["from"] = from
return o
Expand Down Expand Up @@ -142,7 +142,7 @@ func (o Object) SourceFalse() Object {
//
// Returns:
//
// The updated Object with the "_source.includes" parameter set to the specified fields.
// The updated es.Object with the "_source.includes" parameter set to the specified fields.
func (o Object) SourceIncludes(fields ...string) Object {
if len(fields) == 0 {
return o
Expand Down Expand Up @@ -179,7 +179,7 @@ func (o Object) SourceIncludes(fields ...string) Object {
//
// Returns:
//
// The updated Object with the "_source.excludes" parameter set to the specified fields.
// The updated es.Object with the "_source.excludes" parameter set to the specified fields.
func (o Object) SourceExcludes(fields ...string) Object {
if len(fields) == 0 {
return o
Expand All @@ -200,33 +200,33 @@ func (o Object) SourceExcludes(fields ...string) Object {
return o
}

// Sort creates a new sortType object with the specified field.
// Sort creates a new es.sortType object with the specified field.
//
// This function initializes a sortType object with a given field name. The
// This function initializes a es.sortType object with a given field name. The
// field is used to specify the sorting criteria in the search query. The
// resulting sortType can be further configured with sorting order and mode.
// resulting es.sortType can be further configured with sorting order and mode.
//
// Example usage:
//
// s := es.Sort("age")
// // s now includes a sortType with an "age" field that can be further configured.
// // s now includes a es.sortType with an "age" field that can be further configured.
//
// Parameters:
// - field: A string representing the field to sort by.
//
// Returns:
//
// A sortType object with the specified field.
// A es.sortType object with the specified field.
func Sort(field string) sortType {
return sortType{
field: Object{},
}
}

// Order sets the "order" parameter in a sortType object.
// Order sets the "order" parameter in a es.sortType object.
//
// This method specifies the order in which the results should be sorted.
// It configures the sortType object to sort the results in ascending or
// It configures the es.sortType object to sort the results in ascending or
// descending order.
//
// Example usage:
Expand All @@ -239,12 +239,12 @@ func Sort(field string) sortType {
//
// Returns:
//
// The updated sortType object with the "order" parameter set.
// The updated es.sortType object with the "order" parameter set.
func (s sortType) Order(order Order.Order) sortType {
return s.putInTheField("order", order)
}

// Mode sets the "mode" parameter in a sortType object.
// Mode sets the "mode" parameter in a es.sortType object.
//
// This method specifies the mode used for sorting the results. The mode
// determines how sorting should be handled, such as by specifying different
Expand All @@ -260,23 +260,23 @@ func (s sortType) Order(order Order.Order) sortType {
//
// Returns:
//
// The updated sortType object with the "mode" parameter set.
// The updated es.sortType object with the "mode" parameter set.
func (s sortType) Mode(mode Mode.Mode) sortType {
return s.putInTheField("mode", mode)
}

// Sort adds one or more sortType objects to an es.Object.
// Sort adds one or more es.sortType objects to an es.Object.
//
// This method allows you to specify multiple sorting criteria for the search query.
// Each sortType object defines how the results should be sorted based on different fields.
// Each es.sortType object defines how the results should be sorted based on different fields.
//
// Example usage:
//
// query := es.NewQuery(...).Sort(es.Sort("age").Order(Order.Desc), es.Sort("date").Order(Order.Asc))
// // query now includes a "sort" parameter with multiple sortType objects.
// // query now includes a "sort" parameter with multiple es.sortType objects.
//
// Parameters:
// - sorts: A variadic list of sortType objects, each specifying sorting criteria.
// - sorts: A variadic list of es.sortType objects, each specifying sorting criteria.
//
// Returns:
//
Expand Down
Loading

0 comments on commit d8a008a

Please sign in to comment.