Movatterモバイル変換


[0]ホーム

URL:


Notice  The highest tagged major version isv9.

count

package
v8.19.1Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License:Apache-2.0Imports:14Imported by:14

Details

Repository

github.com/elastic/go-elasticsearch

Links

Documentation

Overview

Count search results.Get the number of documents matching a query.

The query can be provided either by using a simple query string as aparameter, or by defining Query DSL within the request body.The query is optional. When no query is provided, the API uses `match_all` tocount all the documents.

The count API supports multi-target syntax. You can run a single count APIsearch across multiple data streams and indices.

The operation is broadcast across all shards.For each shard ID group, a replica is chosen and the search is run againstit.This means that replicas increase the scalability of the count.

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

typeCount

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

funcNew

Count search results.Get the number of documents matching a query.

The query can be provided either by using a simple query string as aparameter, or by defining Query DSL within the request body.The query is optional. When no query is provided, the API uses `match_all` tocount all the documents.

The count API supports multi-target syntax. You can run a single count APIsearch across multiple data streams and indices.

The operation is broadcast across all shards.For each shard ID group, a replica is chosen and the search is run againstit.This means that replicas increase the scalability of the count.

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

func (*Count)AllowNoIndices

func (r *Count) AllowNoIndices(allownoindicesbool) *Count

AllowNoIndices If `false`, the request returns an error if any wildcard expression, indexalias, or `_all` value targets only missing or closed indices.This behavior applies even if the request targets other open indices.For example, a request targeting `foo*,bar*` returns an error if an indexstarts with `foo` but no index starts with `bar`.API name: allow_no_indices

func (*Count)AnalyzeWildcard

func (r *Count) AnalyzeWildcard(analyzewildcardbool) *Count

AnalyzeWildcard If `true`, wildcard and prefix queries are analyzed.This parameter can be used only when the `q` query string parameter isspecified.API name: analyze_wildcard

func (*Count)Analyzer

func (r *Count) Analyzer(analyzerstring) *Count

Analyzer The analyzer to use for the query string.This parameter can be used only when the `q` query string parameter isspecified.API name: analyzer

func (*Count)DefaultOperator

func (r *Count) DefaultOperator(defaultoperatoroperator.Operator) *Count

DefaultOperator The default operator for query string query: `AND` or `OR`.This parameter can be used only when the `q` query string parameter isspecified.API name: default_operator

func (*Count)Df

func (r *Count) Df(dfstring) *Count

Df The field to use as a default when no field prefix is given in the querystring.This parameter can be used only when the `q` query string parameter isspecified.API name: df

func (Count)Do

func (rCount) Do(providedCtxcontext.Context) (*Response,error)

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

func (*Count)ErrorTraceadded inv8.14.0

func (r *Count) ErrorTrace(errortracebool) *Count

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

func (*Count)ExpandWildcards

func (r *Count) ExpandWildcards(expandwildcards ...expandwildcard.ExpandWildcard) *Count

ExpandWildcards The type of index that wildcard patterns can match.If the request can target data streams, this argument determines whetherwildcard expressions match hidden data streams.It supports comma-separated values, such as `open,hidden`.API name: expand_wildcards

func (*Count)FilterPathadded inv8.14.0

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

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

func (*Count)Header

func (r *Count) Header(key, valuestring) *Count

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

func (*Count)HttpRequest

func (r *Count) HttpRequest(ctxcontext.Context) (*http.Request,error)

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

func (*Count)Humanadded inv8.14.0

func (r *Count) Human(humanbool) *Count

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 humanreadable values will be omitted. This makes sense for responses beingconsumedonly by machines.API name: human

func (*Count)IgnoreThrottled

func (r *Count) IgnoreThrottled(ignorethrottledbool) *Count

IgnoreThrottled If `true`, concrete, expanded, or aliased indices are ignored when frozen.API name: ignore_throttled

func (*Count)IgnoreUnavailable

func (r *Count) IgnoreUnavailable(ignoreunavailablebool) *Count

IgnoreUnavailable If `false`, the request returns an error if it targets a missing or closedindex.API name: ignore_unavailable

func (*Count)Index

func (r *Count) Index(indexstring) *Count

Index A comma-separated list of data streams, indices, and aliases to search.It supports wildcards (`*`).To search all data streams and indices, omit this parameter or use `*` or`_all`.API Name: index

func (*Count)Lenient

func (r *Count) Lenient(lenientbool) *Count

Lenient If `true`, format-based query failures (such as providing text to a numericfield) in the query string will be ignored.This parameter can be used only when the `q` query string parameter isspecified.API name: lenient

func (*Count)MinScore

func (r *Count) MinScore(minscorestring) *Count

MinScore The minimum `_score` value that documents must have to be included in theresult.API name: min_score

func (Count)Performadded inv8.7.0

func (rCount) Perform(providedCtxcontext.Context) (*http.Response,error)

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

func (*Count)Preference

func (r *Count) Preference(preferencestring) *Count

Preference The node or shard the operation should be performed on.By default, it is random.API name: preference

func (*Count)Prettyadded inv8.14.0

func (r *Count) Pretty(prettybool) *Count

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

func (*Count)Q

func (r *Count) Q(qstring) *Count

Q The query in Lucene query string syntax. This parameter cannot be used with arequest body.API name: q

func (*Count)Queryadded inv8.9.0

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

Query Defines the search query using Query DSL. A request body query cannot be usedwith the `q` query string parameter.API name: query

func (*Count)Raw

func (r *Count) Raw(rawio.Reader) *Count

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

func (*Count)Request

func (r *Count) Request(req *Request) *Count

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

func (*Count)Routing

func (r *Count) Routing(routingstring) *Count

Routing A custom value used to route operations to a specific shard.API name: routing

func (*Count)TerminateAfter

func (r *Count) TerminateAfter(terminateafterstring) *Count

TerminateAfter The maximum number of documents to collect for each shard.If a query reaches this limit, Elasticsearch terminates the query early.Elasticsearch collects documents before sorting.

IMPORTANT: Use with caution.Elasticsearch applies this parameter to each shard handling the request.When possible, let Elasticsearch perform early termination automatically.Avoid specifying this parameter for requests that target data streams withbacking indices across multiple data tiers.API name: terminate_after

typeNewCount

type NewCount func() *Count

NewCount type alias for index.

funcNewCountFunc

func NewCountFunc(tpelastictransport.Interface)NewCount

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

typeRequest

type Request struct {// Query Defines the search query using Query DSL. A request body query cannot be used// with the `q` query string parameter.Query *types.Query `json:"query,omitempty"`}

Request holds the request body struct for the package count

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/_global/count/CountRequest.ts#L26-L154

funcNewRequestadded inv8.5.0

func NewRequest() *Request

NewRequest returns a Request

func (*Request)FromJSONadded inv8.5.0

func (r *Request) FromJSON(datastring) (*Request,error)

FromJSON allows to load an arbitrary json into the request structure

typeResponseadded inv8.7.0

type Response struct {Countint64                 `json:"count"`Shards_types.ShardStatistics `json:"_shards"`}

Response holds the response body struct for the package count

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/_global/count/CountResponse.ts#L23-L25

funcNewResponseadded inv8.7.0

func NewResponse() *Response

NewResponse returns a Response

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp