common

package
v0.0.0-...-dcf8ddf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunJSONTests

func RunJSONTests(t *testing.T, tests []JsonTest)

func RunMapTests

func RunMapTests(t *testing.T, tests []MapTest)

Types

type Aggregation

type Aggregation interface {
	Mappable
	Name() string
}

Aggregation is an interface that each aggregation type must implement. It is simply an extension of the Mappable interface to include a Named function, which returns the name of the aggregation.

type CountRequest

type CountRequest struct {
	// contains filtered or unexported fields
}

CountRequest represents a request to get the number of matches for a search query, as described in: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html

func Count

func Count(q Mappable) *CountRequest

Count creates a new count request with the provided query.

func (*CountRequest) Map

func (req *CountRequest) Map() map[string]interface{}

Map returns a map representation of the request, thus implementing the Mappable interface.

func (*CountRequest) Run

func (req *CountRequest) Run(
	api *elasticsearch.Client,
	o ...func(*esapi.CountRequest),
) (res *esapi.Response, err error)

Run executes the request using the provided ElasticCount client. Zero or more search options can be provided as well. It returns the standard Response type of the official Go client.

func (*CountRequest) RunCount

func (req *CountRequest) RunCount(
	count esapi.Count,
	o ...func(*esapi.CountRequest),
) (res *esapi.Response, err error)

RunCount is the same as the Run method, except that it accepts a value of type esapi.Count (usually this is the Count field of an elasticsearch.Client object). Since the ElasticCount client does not provide an interface type for its API (which would allow implementation of mock clients), this provides a workaround. The Count function in the ES client is actually a field of a function type.

type DeleteRequest

type DeleteRequest struct {
	// contains filtered or unexported fields
}

DeleteRequest represents a request to ElasticSearch's Delete By Query API, described in https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html

func Delete

func Delete() *DeleteRequest

Delete creates a new DeleteRequest object, to be filled via method chaining.

func (*DeleteRequest) Index

func (req *DeleteRequest) Index(index ...string) *DeleteRequest

Index sets the index names for the request

func (*DeleteRequest) Query

func (req *DeleteRequest) Query(q Mappable) *DeleteRequest

Query sets a query for the request.

func (*DeleteRequest) Run

func (req *DeleteRequest) Run(
	api *elasticsearch.Client,
	o ...func(*esapi.DeleteByQueryRequest),
) (res *esapi.Response, err error)

Run executes the request using the provided ElasticSearch client.

func (*DeleteRequest) RunDelete

func (req *DeleteRequest) RunDelete(
	del esapi.DeleteByQuery,
	o ...func(*esapi.DeleteByQueryRequest),
) (res *esapi.Response, err error)

RunDelete is the same as the Run method, except that it accepts a value of type esapi.DeleteByQuery (usually this is the DeleteByQuery field of an elasticsearch.Client object). Since the ElasticSearch client does not provide an interface type for its API (which would allow implementation of mock clients), this provides a workaround. The Delete function in the ES client is actually a field of a function type.

type HighlightBoundaryScanner

type HighlightBoundaryScanner uint8
const (
	BoundaryScannerDefault HighlightBoundaryScanner = iota

	// BoundaryScannerChars is the "chars" value
	BoundaryScannerChars

	// BoundaryScannerSentence is the "sentence" value
	BoundaryScannerSentence

	// BoundaryScannerWord is the "word" value
	BoundaryScannerWord
)

func (HighlightBoundaryScanner) String

func (a HighlightBoundaryScanner) String() string

String returns a string representation of the boundary_scanner parameter, as known to ElasticSearch.

type HighlightEncoder

type HighlightEncoder uint8
const (
	// EncoderDefault is the "default" value
	EncoderDefault HighlightEncoder = iota

	// EncoderHtml is the "html" value
	EncoderHtml
)

func (HighlightEncoder) String

func (a HighlightEncoder) String() string

String returns a string representation of the encoder parameter, as known to ElasticSearch.

type HighlightFragmenter

type HighlightFragmenter uint8
const (
	// FragmentSpan is the "span" value
	FragmenterSpan HighlightFragmenter = iota

	// FragmenterSimple is the "simple" value
	FragmenterSimple
)

func (HighlightFragmenter) String

func (a HighlightFragmenter) String() string

String returns a string representation of the fragmenter parameter, as known to ElasticSearch.

type HighlightOrder

type HighlightOrder uint8
const (
	// OrderNone is the "none" value
	OrderNone HighlightOrder = iota

	// OrderScore is the "score" value
	OrderScore
)

func (HighlightOrder) String

func (a HighlightOrder) String() string

String returns a string representation of the order parameter, as known to ElasticSearch.

type HighlightTagsSchema

type HighlightTagsSchema uint8
const (
	TagsSchemaDefault HighlightTagsSchema = iota
	// TagsSchemaStyled is the "styled" value
	TagsSchemaStyled
)

func (HighlightTagsSchema) String

func (a HighlightTagsSchema) String() string

String returns a string representation of the tags_schema parameter, as known to ElasticSearch.

type HighlightType

type HighlightType uint8
const (
	// HighlighterUnified is the "unified" value
	HighlighterUnified HighlightType = iota

	// HighlighterPlain is the "plain" value
	HighlighterPlain

	// HighlighterFvh is the "fvh" value
	HighlighterFvh
)

func (HighlightType) String

func (a HighlightType) String() string

String returns a string representation of the type parameter, as known to ElasticSearch.

type JsonTest

type JsonTest struct {
	Name    string
	M       json.Marshaler
	ExpJSON string
	ExpErr  error
}

type MapTest

type MapTest struct {
	Name string
	M    Mappable
	Exp  map[string]interface{}
}

type Mappable

type Mappable interface {
	Map() map[string]interface{}
}

Mappable is the interface implemented by the various query and aggregation types provided by the package. It allows the library to easily transform the different queries to "generic" maps that can be easily encoded to JSON.

type Order

type Order string

Order is the ordering for a sort key (ascending, descending).

const (
	// OrderAsc represents sorting in ascending order.
	OrderAsc Order = "asc"

	// OrderDesc represents sorting in descending order.
	OrderDesc Order = "desc"
)

type QueryHighlight

type QueryHighlight struct {
	// contains filtered or unexported fields
}

func Highlight

func Highlight() *QueryHighlight

Highlight creates a new "query" of type "highlight"

func (*QueryHighlight) BoundaryChars

func (q *QueryHighlight) BoundaryChars(s string) *QueryHighlight

BoundaryChars sets the highlight query's boundary_chars ignore unmapped field

func (*QueryHighlight) BoundaryMaxScan

func (q *QueryHighlight) BoundaryMaxScan(i uint16) *QueryHighlight

BoundaryMaxScan sets the highlight query's boundary_max_scan ignore unmapped field

func (*QueryHighlight) BoundaryScanner

BoundaryScanner sets the highlight query's boundary_scanner ignore unmapped field

func (*QueryHighlight) BoundaryScannerLocale

func (q *QueryHighlight) BoundaryScannerLocale(l string) *QueryHighlight

BoundaryScannerLocale sets the highlight query's boundary_scanner_locale ignore unmapped field

func (*QueryHighlight) Encoder

Encoder sets the highlight query's encoder ignore unmapped field

func (*QueryHighlight) Field

func (q *QueryHighlight) Field(name string, h ...*QueryHighlight) *QueryHighlight

Field sets an entry the highlight query's fields

func (*QueryHighlight) Fields

Fields sets all entries for the highlight query's fields

func (*QueryHighlight) ForceSource

func (q *QueryHighlight) ForceSource(b bool) *QueryHighlight

ForceSource sets the highlight query's force_source ignore unmapped field

func (*QueryHighlight) FragmentOffset

func (q *QueryHighlight) FragmentOffset(i uint16) *QueryHighlight

FragmentOffset sets the highlight query's fragment_offset ignore unmapped field

func (*QueryHighlight) FragmentSize

func (q *QueryHighlight) FragmentSize(i uint16) *QueryHighlight

FragmentSize sets the highlight query's fragment_size ignore unmapped field

func (*QueryHighlight) Fragmenter

Fragmenter sets the highlight query's fragmenter ignore unmapped field

func (*QueryHighlight) HighlightQuery

func (q *QueryHighlight) HighlightQuery(b Mappable) *QueryHighlight

HighlightQuery sets the highlight query's highlight_query ignore unmapped field

func (*QueryHighlight) Map

func (q *QueryHighlight) Map() map[string]interface{}

Map returns a map representation of the highlight; implementing the Mappable interface.

func (*QueryHighlight) MatchedFields

func (q *QueryHighlight) MatchedFields(s ...string) *QueryHighlight

MatchedFields sets the highlight query's matched_fields ignore unmapped field

func (*QueryHighlight) NoMatchSize

func (q *QueryHighlight) NoMatchSize(i uint16) *QueryHighlight

NoMatchSize sets the highlight query's no_match_size ignore unmapped field

func (*QueryHighlight) NumberOfFragments

func (q *QueryHighlight) NumberOfFragments(i uint16) *QueryHighlight

NumberOfFragments sets the highlight query's number_of_fragments ignore unmapped field

func (*QueryHighlight) Order

Order sets the nested highlight's score order unmapped field

func (*QueryHighlight) PhraseLimit

func (q *QueryHighlight) PhraseLimit(i uint16) *QueryHighlight

PhraseLimit sets the highlight query's phrase_limit ignore unmapped field

func (*QueryHighlight) PostTags

func (q *QueryHighlight) PostTags(s ...string) *QueryHighlight

PostTags sets the highlight query's post_tags ignore unmapped field

func (*QueryHighlight) PreTags

func (q *QueryHighlight) PreTags(s ...string) *QueryHighlight

PreTags sets the highlight query's pre_tags ignore unmapped field

func (*QueryHighlight) RequireFieldMatch

func (q *QueryHighlight) RequireFieldMatch(b bool) *QueryHighlight

RequireFieldMatch sets the highlight query's require_field_match ignore unmapped field

func (*QueryHighlight) TagsSchema

TagsSchema sets the highlight query's tags_schema ignore unmapped field

func (*QueryHighlight) Type

Type sets the highlight query's type ignore unmapped field

type Sort

type Sort []map[string]interface{}

Sort represents a list of keys to sort by.

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source represents the "_source" option which is commonly accepted in ES queries. Currently, only the "includes" option is supported.

func (*Source) GetExcludes

func (source *Source) GetExcludes() []string

func (*Source) GetIncludes

func (source *Source) GetIncludes() []string

func (*Source) Map

func (source *Source) Map() map[string]interface{}

Map returns a map representation of the Source object.

func (*Source) SetExcludes

func (source *Source) SetExcludes(excludes []string)

func (*Source) SetIncludes

func (source *Source) SetIncludes(includes []string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL