FIX import & go.sum & simple issues

This commit is contained in:
Maxim Yanchuk 2023-11-02 00:30:33 +03:00
parent bc3cec49c2
commit 90226c236a
12 changed files with 51 additions and 60 deletions

View File

@ -6,7 +6,7 @@ type FilterAggregation struct {
aggs []Aggregation
}
// Filter creates a new aggregation of type "filter". The method name includes
// FilterAgg creates a new aggregation of type "filter". The method name includes
// the "Agg" suffix to prevent conflict with the "filter" query.
func FilterAgg(name string, filter Mappable) *FilterAggregation {
return &FilterAggregation{

View File

@ -44,8 +44,7 @@ func (agg *BaseAgg) Map() map[string]interface{} {
}
// AvgAgg represents an aggregation of type "avg", as described in
// https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-avg-aggregation.html
// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html
type AvgAgg struct {
*BaseAgg `structs:",flatten"`
}
@ -68,8 +67,7 @@ func (agg *AvgAgg) Missing(val interface{}) *AvgAgg {
//----------------------------------------------------------------------------//
// WeightedAvgAgg represents an aggregation of type "weighted_avg", as described
// in https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-weight-avg-aggregation.html
// in https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-weight-avg-aggregation.html
type WeightedAvgAgg struct {
name string
apiName string
@ -106,7 +104,7 @@ func (agg *WeightedAvgAgg) Value(field string, missing ...interface{}) *Weighted
return agg
}
// Value sets the weight field and optionally a value to use when records are
// Weight sets the weight field and optionally a value to use when records are
// missing a value for the field.
func (agg *WeightedAvgAgg) Weight(field string, missing ...interface{}) *WeightedAvgAgg {
agg.Weig = new(BaseAggParams)
@ -128,8 +126,7 @@ func (agg *WeightedAvgAgg) Map() map[string]interface{} {
//----------------------------------------------------------------------------//
// CardinalityAgg represents an aggregation of type "cardinality", as described
// in https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-cardinality-aggregation.html
// in https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
type CardinalityAgg struct {
*BaseAgg `structs:",flatten"`
@ -169,8 +166,7 @@ func (agg *CardinalityAgg) Map() map[string]interface{} {
//----------------------------------------------------------------------------//
// MaxAgg represents an aggregation of type "max", as described in:
// https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-max-aggregation.html
// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html
type MaxAgg struct {
*BaseAgg `structs:",flatten"`
}
@ -193,8 +189,7 @@ func (agg *MaxAgg) Missing(val interface{}) *MaxAgg {
//----------------------------------------------------------------------------//
// MinAgg represents an aggregation of type "min", as described in:
// https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-min-aggregation.html
// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-min-aggregation.html
type MinAgg struct {
*BaseAgg `structs:",flatten"`
}
@ -217,8 +212,7 @@ func (agg *MinAgg) Missing(val interface{}) *MinAgg {
//----------------------------------------------------------------------------//
// SumAgg represents an aggregation of type "sum", as described in:
// https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-sum-aggregation.html
// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html
type SumAgg struct {
*BaseAgg `structs:",flatten"`
}
@ -241,8 +235,7 @@ func (agg *SumAgg) Missing(val interface{}) *SumAgg {
//----------------------------------------------------------------------------//
// ValueCountAgg represents an aggregation of type "value_count", as described
// in https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-valuecount-aggregation.html
// in https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html
type ValueCountAgg struct {
*BaseAgg `structs:",flatten"`
}
@ -258,8 +251,7 @@ func ValueCount(name, field string) *ValueCountAgg {
//----------------------------------------------------------------------------//
// PercentilesAgg represents an aggregation of type "percentiles", as described
// in https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-percentile-aggregation.html
// in https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html
type PercentilesAgg struct {
*BaseAgg `structs:",flatten"`
@ -334,8 +326,7 @@ func (agg *PercentilesAgg) Map() map[string]interface{} {
//----------------------------------------------------------------------------//
// StatsAgg represents an aggregation of type "stats", as described in:
// https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-stats-aggregation.html
// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html
type StatsAgg struct {
*BaseAgg `structs:",flatten"`
}
@ -357,8 +348,7 @@ func (agg *StatsAgg) Missing(val interface{}) *StatsAgg {
// ---------------------------------------------------------------------------//
// StringStatsAgg represents an aggregation of type "string_stats", as described
// in https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-string-stats-aggregation.html
// in https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-string-stats-aggregation.html
type StringStatsAgg struct {
*BaseAgg `structs:",flatten"`
@ -399,8 +389,7 @@ func (agg *StringStatsAgg) Map() map[string]interface{} {
// ---------------------------------------------------------------------------//
// TopHitsAgg represents an aggregation of type "top_hits", as described
// in https://www.elastic.co/guide/en/elasticsearch/reference/
// current/search-aggregations-metrics-top-hits-aggregation.html
// in https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html
type TopHitsAgg struct {
name string
from uint64

View File

@ -20,7 +20,7 @@ func (agg *NestedAggregation) Name() string {
return agg.name
}
// NumberOfFragments sets the aggregations path
// Path sets the aggregations path
func (agg *NestedAggregation) Path(p string) *NestedAggregation {
agg.path = p
return agg

View File

@ -21,7 +21,7 @@ func CustomQuery(m map[string]interface{}) *CustomQueryMap {
// Map returns the custom query as a map[string]interface{}, thus implementing
// the Mappable interface.
func (m *CustomQueryMap) Map() map[string]interface{} {
return map[string]interface{}(*m)
return *m
}
// Run executes the custom query using the provided ElasticSearch client. Zero

8
go.sum
View File

@ -1,7 +1,7 @@
github.com/elastic/elastic-transport-go/v8 v8.1.0 h1:NeqEz1ty4RQz+TVbUrpSU7pZ48XkzGWQj02k5koahIE=
github.com/elastic/elastic-transport-go/v8 v8.1.0/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI=
github.com/elastic/go-elasticsearch/v8 v8.4.0 h1:Rn1mcqaIMcNT43hnx2H62cIFZ+B6mjWtzj85BDKrvCE=
github.com/elastic/go-elasticsearch/v8 v8.4.0/go.mod h1:yY52i2Vj0unLz+N3Nwx1gM5LXwoj3h2dgptNGBYkMLA=
github.com/elastic/elastic-transport-go/v8 v8.3.0 h1:DJGxovyQLXGr62e9nDMPSxRyWION0Bh6d9eCFBriiHo=
github.com/elastic/elastic-transport-go/v8 v8.3.0/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI=
github.com/elastic/go-elasticsearch/v8 v8.10.1 h1:JJ3i2DimYTsJcUoEGbg6tNB0eehTNdid9c5kTR1TGuI=
github.com/elastic/go-elasticsearch/v8 v8.10.1/go.mod h1:GU1BJHO7WeamP7UhuElYwzzHtvf9SDmeVpSSy9+o6Qg=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/jgroeneveld/schema v1.0.0 h1:J0E10CrOkiSEsw6dfb1IfrDJD14pf6QLVJ3tRPl/syI=

View File

@ -252,9 +252,10 @@ func (a HighlightBoundaryScanner) String() string {
return "sentence"
case BoundaryScannerWord:
return "word"
}
default:
return ""
}
}
type HighlightEncoder uint8
@ -281,7 +282,7 @@ func (a HighlightEncoder) String() string {
type HighlightFragmenter uint8
const (
// FragmentSpan is the "span" value
// FragmenterSpan is the "span" value
FragmenterSpan HighlightFragmenter = iota
// FragmenterSimple is the "simple" value
@ -336,6 +337,7 @@ func (a HighlightTagsSchema) String() string {
switch a {
case TagsSchemaStyled:
return "styled"
}
default:
return ""
}
}

View File

@ -32,7 +32,7 @@ func (q *BoolQuery) Filter(filter ...Mappable) *BoolQuery {
return q
}
// Must adds one or more queries of type "must_not" to the bool query. MustNot
// MustNot adds one or more queries of type "must_not" to the bool query. MustNot
// can be called multiple times, queries will be appended to existing ones.
func (q *BoolQuery) MustNot(mustnot ...Mappable) *BoolQuery {
q.mustNot = append(q.mustNot, mustnot...)

View File

@ -57,7 +57,7 @@ func (q *CombinedFieldsQuery) AutoGenerateSynonymsPhraseQuery(b bool) *CombinedF
return q
}
// Boost
// Boost sets the query boost
func (q *CombinedFieldsQuery) Boost(l float32) *CombinedFieldsQuery {
q.params.Boost = l
return q
@ -83,4 +83,3 @@ func (q *CombinedFieldsQuery) ZeroTermsQuery(s ZeroTerms) *CombinedFieldsQuery {
q.params.ZeroTerms = s
return q
}

View File

@ -10,7 +10,7 @@ const (
// TypeMatch denotes a query of type "match"
TypeMatch matchType = iota
// TypeMatchBool denotes a query of type "match_bool_prefix"
// TypeMatchBoolPrefix denotes a query of type "match_bool_prefix"
TypeMatchBoolPrefix
// TypeMatchPhrase denotes a query of type "match_phrase"
@ -204,9 +204,9 @@ func (q *MatchQuery) ZeroTermsQuery(s ZeroTerms) *MatchQuery {
}
// Boost sets the boost value of the query.
func (a *MatchQuery) Boost(b float32) *MatchQuery {
a.params.Boost = b
return a
func (q *MatchQuery) Boost(b float32) *MatchQuery {
q.params.Boost = b
return q
}
// MatchOperator is an enumeration type representing supported values for a

View File

@ -100,13 +100,13 @@ func (q *MultiMatchQuery) PrefixLength(l uint16) *MultiMatchQuery {
return q
}
// TieBreaker
// TieBreaker sets the query tiebreaker
func (q *MultiMatchQuery) TieBreaker(l float32) *MultiMatchQuery {
q.params.TieBrk = l
return q
}
// Boost
// Boost sets the query boost
func (q *MultiMatchQuery) Boost(l float32) *MultiMatchQuery {
q.params.Boost = l
return q
@ -164,27 +164,27 @@ func (q *MultiMatchQuery) ZeroTermsQuery(s ZeroTerms) *MultiMatchQuery {
return q
}
// MatchType is an enumeration type representing supported values for a
// MultiMatchType is an enumeration type representing supported values for a
// multi match query's "type" parameter.
type MultiMatchType uint8
const (
// TypeBestFields is the "best_fields" type
// MatchTypeBestFields is the "best_fields" type
MatchTypeBestFields MultiMatchType = iota
// TypeMostFields is the "most_fields" type
// MatchTypeMostFields is the "most_fields" type
MatchTypeMostFields
// TypeMostFields is the "cross_fields" type
// MatchTypeCrossFields is the "cross_fields" type
MatchTypeCrossFields
// TypeMostFields is the "phrase" type
// MatchTypePhrase is the "phrase" type
MatchTypePhrase
// TypeMostFields is the "phrase_prefix" type
// MatchTypePhrasePrefix is the "phrase_prefix" type
MatchTypePhrasePrefix
// TypeMostFields is the "bool_prefix" type
// MatchTypeBoolPrefix is the "bool_prefix" type
MatchTypeBoolPrefix
)

View File

@ -122,7 +122,7 @@ func (a *RangeQuery) Gt(val interface{}) *RangeQuery {
return a
}
// Gt sets that the value of field must be greater than or equal to the provided
// Gte sets that the value of field must be greater than or equal to the provided
// value
func (a *RangeQuery) Gte(val interface{}) *RangeQuery {
a.params.Gte = val
@ -454,7 +454,7 @@ func (q *TermsQuery) Boost(b float32) *TermsQuery {
// Map returns a map representation of the query, thus implementing the
// Mappable interface.
func (q TermsQuery) Map() map[string]interface{} {
func (q *TermsQuery) Map() map[string]interface{} {
innerMap := map[string]interface{}{q.field: q.values}
if q.boost > 0 {
innerMap["boost"] = q.boost
@ -511,7 +511,7 @@ func (q *TermsSetQuery) MinimumShouldMatchScript(script string) *TermsSetQuery {
// Map returns a map representation of the query, thus implementing the
// Mappable interface.
func (q TermsSetQuery) Map() map[string]interface{} {
func (q *TermsSetQuery) Map() map[string]interface{} {
return map[string]interface{}{
"terms_set": map[string]interface{}{
q.field: structs.Map(q.params),
@ -519,7 +519,7 @@ func (q TermsSetQuery) Map() map[string]interface{} {
}
}
// geoFilterParams represents a query of type "geo_distance", as described in:
// GeoFilter geoFilterParams represents a query of type "geo_distance", as described in:
// https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl-geo-distance-query.html
type GeoFilter struct {
params geoFilterParams

View File

@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/elastic/go-elasticsearch/v8"
"time"
"github.com/elastic/go-elasticsearch/v8/esapi"