rollupsearch

package
v8.18.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Overview

Search rolled-up data. The rollup search endpoint is needed because, internally, rolled-up documents utilize a different document structure than the original data. It rewrites standard Query DSL into a format that matches the rollup documents then takes the response and rewrites it back to what a client would expect given the original query.

The request body supports a subset of features from the regular search API. The following functionality is not available:

`size`: Because rollups work on pre-aggregated data, no search hits can be returned and so size must be set to zero or omitted entirely. `highlighter`, `suggestors`, `post_filter`, `profile`, `explain`: These are similarly disallowed.

**Searching both historical rollup and non-rollup data**

The rollup search API has the capability to search across both "live" non-rollup data and the aggregated rollup data. This is done by simply adding the live indices to the URI. For example:

``` GET sensor-1,sensor_rollup/_rollup_search

{
  "size": 0,
  "aggregations": {
     "max_temperature": {
      "max": {
        "field": "temperature"
      }
    }
  }
}

```

The rollup search endpoint does two things when the search runs:

* The original request is sent to the non-rollup index unaltered. * A rewritten version of the original request is sent to the rollup index.

When the two responses are received, the endpoint rewrites the rollup response and merges the two together. During the merging process, if there is any overlap in buckets between the two responses, the buckets from the non-rollup index are used.

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildPath = errors.New("cannot build path, check for missing path parameters")

ErrBuildPath is returned in case of missing parameters within the build of the request.

Functions

This section is empty.

Types

type NewRollupSearch

type NewRollupSearch func(index string) *RollupSearch

NewRollupSearch type alias for index.

func NewRollupSearchFunc

func NewRollupSearchFunc(tp elastictransport.Interface) NewRollupSearch

NewRollupSearchFunc returns a new instance of RollupSearch with the provided transport. Used in the index of the library this allows to retrieve every apis in once place.

type Request

type Request struct {

	// Aggregations Specifies aggregations.
	Aggregations map[string]types.Aggregations `json:"aggregations,omitempty"`
	// Query Specifies a DSL query that is subject to some limitations.
	Query *types.Query `json:"query,omitempty"`
	// Size Must be zero if set, as rollups work on pre-aggregated data.
	Size *int `json:"size,omitempty"`
}

Request holds the request body struct for the package rollupsearch

https://github.com/elastic/elasticsearch-specification/blob/3a94b6715915b1e9311724a2614c643368eece90/specification/rollup/rollup_search/RollupSearchRequest.ts#L27-L109

func NewRequest added in v8.5.0

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON added in v8.5.0

func (r *Request) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request) UnmarshalJSON added in v8.12.1

func (s *Request) UnmarshalJSON(data []byte) error

type Response added in v8.7.0

type Response struct {
	Aggregations    map[string]types.Aggregate `json:"aggregations,omitempty"`
	Hits            types.HitsMetadata         `json:"hits"`
	Shards_         types.ShardStatistics      `json:"_shards"`
	TerminatedEarly *bool                      `json:"terminated_early,omitempty"`
	TimedOut        bool                       `json:"timed_out"`
	Took            int64                      `json:"took"`
}

Response holds the response body struct for the package rollupsearch

https://github.com/elastic/elasticsearch-specification/blob/3a94b6715915b1e9311724a2614c643368eece90/specification/rollup/rollup_search/RollupSearchResponse.ts#L27-L36

func NewResponse added in v8.7.0

func NewResponse() *Response

NewResponse returns a Response

func (*Response) UnmarshalJSON added in v8.7.0

func (s *Response) UnmarshalJSON(data []byte) error

type RollupSearch

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

func New

Search rolled-up data. The rollup search endpoint is needed because, internally, rolled-up documents utilize a different document structure than the original data. It rewrites standard Query DSL into a format that matches the rollup documents then takes the response and rewrites it back to what a client would expect given the original query.

The request body supports a subset of features from the regular search API. The following functionality is not available:

`size`: Because rollups work on pre-aggregated data, no search hits can be returned and so size must be set to zero or omitted entirely. `highlighter`, `suggestors`, `post_filter`, `profile`, `explain`: These are similarly disallowed.

**Searching both historical rollup and non-rollup data**

The rollup search API has the capability to search across both "live" non-rollup data and the aggregated rollup data. This is done by simply adding the live indices to the URI. For example:

``` GET sensor-1,sensor_rollup/_rollup_search

{
  "size": 0,
  "aggregations": {
     "max_temperature": {
      "max": {
        "field": "temperature"
      }
    }
  }
}

```

The rollup search endpoint does two things when the search runs:

* The original request is sent to the non-rollup index unaltered. * A rewritten version of the original request is sent to the rollup index.

When the two responses are received, the endpoint rewrites the rollup response and merges the two together. During the merging process, if there is any overlap in buckets between the two responses, the buckets from the non-rollup index are used.

https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-search.html

func (*RollupSearch) Aggregations added in v8.9.0

func (r *RollupSearch) Aggregations(aggregations map[string]types.Aggregations) *RollupSearch

Aggregations Specifies aggregations. API name: aggregations

func (RollupSearch) Do

func (r RollupSearch) Do(providedCtx context.Context) (*Response, error)

Do runs the request through the transport, handle the response and returns a rollupsearch.Response

func (*RollupSearch) ErrorTrace added in v8.14.0

func (r *RollupSearch) ErrorTrace(errortrace bool) *RollupSearch

ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errors when they occur. API name: error_trace

func (*RollupSearch) FilterPath added in v8.14.0

func (r *RollupSearch) FilterPath(filterpaths ...string) *RollupSearch

FilterPath Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch. API name: filter_path

func (*RollupSearch) Header

func (r *RollupSearch) Header(key, value string) *RollupSearch

Header set a key, value pair in the RollupSearch headers map.

func (*RollupSearch) HttpRequest

func (r *RollupSearch) HttpRequest(ctx context.Context) (*http.Request, error)

HttpRequest returns the http.Request object built from the given parameters.

func (*RollupSearch) Human added in v8.14.0

func (r *RollupSearch) Human(human bool) *RollupSearch

Human When set to `true` will return statistics in a format suitable for humans. For example `"exists_time": "1h"` for humans and `"eixsts_time_in_millis": 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines. API name: human

func (RollupSearch) Perform added in v8.7.0

func (r RollupSearch) Perform(providedCtx context.Context) (*http.Response, error)

Perform runs the http.Request through the provided transport and returns an http.Response.

func (*RollupSearch) Pretty added in v8.14.0

func (r *RollupSearch) Pretty(pretty bool) *RollupSearch

Pretty If set to `true` the returned JSON will be "pretty-formatted". Only use this option for debugging only. API name: pretty

func (*RollupSearch) Query added in v8.9.0

func (r *RollupSearch) Query(query *types.Query) *RollupSearch

Query Specifies a DSL query that is subject to some limitations. API name: query

func (*RollupSearch) Raw

func (r *RollupSearch) Raw(raw io.Reader) *RollupSearch

Raw takes a json payload as input which is then passed to the http.Request If specified Raw takes precedence on Request method.

func (*RollupSearch) Request

func (r *RollupSearch) Request(req *Request) *RollupSearch

Request allows to set the request property with the appropriate payload.

func (*RollupSearch) RestTotalHitsAsInt

func (r *RollupSearch) RestTotalHitsAsInt(resttotalhitsasint bool) *RollupSearch

RestTotalHitsAsInt Indicates whether hits.total should be rendered as an integer or an object in the rest search response API name: rest_total_hits_as_int

func (*RollupSearch) Size added in v8.9.0

func (r *RollupSearch) Size(size int) *RollupSearch

Size Must be zero if set, as rollups work on pre-aggregated data. API name: size

func (*RollupSearch) TypedKeys

func (r *RollupSearch) TypedKeys(typedkeys bool) *RollupSearch

TypedKeys Specify whether aggregation and suggester names should be prefixed by their respective types in the response API name: typed_keys

Jump to

Keyboard shortcuts

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