Module contents

Submodules

esorm.aggs module

ElasticSearch aggregation type definitions for ESORM

class esorm.aggs.ESAgg(*args, **kwargs)[source]

Bases: dict

Holds all types of aggregations supported

avg: ESAggFieldParams

Average aggregation

histogram: ESAggHistogramParams

Histogram aggregation

max: ESAggFieldParams

Maximum aggregation

min: ESAggFieldParams

Minimum aggregation

sum: ESAggFieldParams

Sum aggregation

terms: ESAggTermParams

Terms aggregation

class esorm.aggs.ESAggBucketResponse(*args, **kwargs)[source]

Bases: dict

Represents a single bucket in a bucket aggregation.

doc_count: int

The number of documents in this bucket.

key: str

The key of the bucket.

class esorm.aggs.ESAggExtendedBounds(*args, **kwargs)[source]

Bases: dict

Represents the parameters for extended bounds in Elasticsearch.

max: int

The maximum value.

min: int

The minimum value.

class esorm.aggs.ESAggFieldParams(*args, **kwargs)[source]

Bases: dict

Represents field parameter in Elasticsearch.

field: str

The field to aggregate on.

class esorm.aggs.ESAggHistogramBucketresponse(*args, **kwargs)[source]

Bases: dict

Represents a bucket in a histogram aggregation.

doc_count: int

The number of documents in this bucket.

key: float

Numeric key corresponding to the bucket’s range.

class esorm.aggs.ESAggHistogramParams(*args, **kwargs)[source]

Bases: dict

Represents the parameters for a histogram aggregation in Elasticsearch.

extended_bounds: ESAggExtendedBounds

The extended bounds of the histogram.

field: str

The field to aggregate on.

interval: int

The interval of the histogram.

min_doc_count: int

The minimum number of documents in a bucket.

class esorm.aggs.ESAggHistogramResponse(*args, **kwargs)[source]

Bases: dict

Represents the response for a histogram aggregation.

buckets: List[ESAggHistogramBucketresponse]

A list of buckets in the histogram aggregation.

class esorm.aggs.ESAggTermParams(*args, **kwargs)[source]

Bases: dict

Represents the parameters for a terms aggregation in Elasticsearch.

field: str

The field to aggregate on.

order: Dict[str, str]

The order of the buckets.

size: int

The number of buckets to return.

class esorm.aggs.ESAggTermsResponse(*args, **kwargs)[source]

Bases: dict

Represents the response for a terms aggregation.

buckets: List[ESAggBucketResponse]

A list of buckets in the terms aggregation.

class esorm.aggs.ESAggValueResponse(*args, **kwargs)[source]

Bases: dict

Represents the response for an average, min, or max aggregation.

value: float

The average, min, or max value.

esorm.aggs.ESAggs

ElasticSearch aggregations type definition

alias of Dict[str, ESAgg]

esorm.aggs.ESAggsResponse

ElasticSearch aggregations response type definition

alias of Dict[str, Union[ESAggValueResponse, ESAggTermsResponse, ESAggHistogramResponse]]

esorm.bulk module

esorm.error module

This module contains all the exceptions that can be raised by ESORM.

exception esorm.error.BulkError(failed_operations)[source]

Bases: Exception

Exception for handling bulk operation errors.

failed_operations: List[BulkOperationError]
class esorm.error.BulkOperationError(*args, **kwargs)[source]

Bases: dict

A dictionary type to represent an error in a bulk operation response from Elasticsearch.

model: ESModel
reason: str
status: int
type: str
exception esorm.error.IndexDoesNotFoundError[source]

Bases: Exception

Raised when an index does not exist.

exception esorm.error.InvalidModelError[source]

Bases: Exception

Raised when a model is invalid.

exception esorm.error.InvalidResponseError[source]

Bases: Exception

Raised when the response from Elasticsearch is invalid.

exception esorm.error.NotFoundError[source]

Bases: Exception

Raised when a model is not found.

esorm.esorm module

esorm.fastapi module

esorm.fields module

esorm.logger module

esorm.model module

esorm.query module

esorm.response module

esorm.utils module

Utility functions

esorm.utils.camel_case(snake_str, capitalize_first=False)[source]

Convert to camel case

Parameters:
  • snake_str (str) – The string to convert to camel case

  • capitalize_first (bool) – Capitalize the first letter

Returns:

Converted string

esorm.utils.snake_case(camel_str)[source]

Convert to snake case

Parameters:

camel_str (str) – The string to convert to snake case

Returns:

Converted string

esorm.utils.utcnow()[source]

Get current UTC time

Returns:

Current UTC time

esorm.watcher module