API Documentation¶
Simple Conveniences for Talking to Elasticsearch
elastalk.config¶
Make things work the way you want!
-
class
elastalk.config.
BlobConf
(enabled: bool = None, excluded: Set[str] = <factory>, key: str = None)[source]¶ Bases:
object
Define blobbing parameters.
-
__init__
(enabled: bool = None, excluded: Set[str] = <factory>, key: str = None) → None¶
-
enabled
= None¶ indicates whether or not blobbing is enabled.
-
exclude
(*keys)[source]¶ Add to the set of excluded document keys.
- Parameters
keys – the excluded document keys
-
excluded
= None¶ the excluded top-level document keys
-
key
= None¶ the key that stores blobbed values in packed documents
-
-
class
elastalk.config.
ElastalkConf
(seeds: Iterable[str] = <factory>, sniff_on_start: bool = True, sniff_on_connection_fail: bool = True, sniffer_timeout: int = 60, maxsize: int = 10, mapping_field_limit: int = 1000, blobs: elastalk.config.BlobConf = BlobConf(enabled=None, excluded=set(), key=None), indexes: Dict[str, elastalk.config.IndexConf] = <factory>)[source]¶ Bases:
object
Configuration options for an Elastalk and the Elasticsearch client.
-
__init__
(seeds: Iterable[str] = <factory>, sniff_on_start: bool = True, sniff_on_connection_fail: bool = True, sniffer_timeout: int = 60, maxsize: int = 10, mapping_field_limit: int = 1000, blobs: elastalk.config.BlobConf = BlobConf(enabled=None, excluded=set(), key=None), indexes: Dict[str, elastalk.config.IndexConf] = <factory>) → None¶
-
blob_exclusions
[source]¶ Get the full set of top-level document properties that should be excluded from blobs for a given index. If you don’t supply the index parameter, the method returns the global exclusions.
- Parameters
index – the name of the index
- Returns
the set of excluded property names
-
blob_key
(index: str = None) → str[source]¶ Get the configured document key for blobbed data. (If you don’t supply the index, the method returns the global configuration value. If there is no global configuration value, the method returns the default.)
- Parameters
index – the name of the index
- Returns
the blobbed data key
-
blobs
= BlobConf(enabled=None, excluded=set(), key=None)¶ global BLOB behavior configuration
-
blobs_enabled
[source]¶ Determine whether or not blobbing is enabled for an index.
- Parameters
index – the name of the index
- Returns
True if blobbing is enabled, otherwise False
-
from_object
(o: str) → elastalk.config.ElastalkConf[source]¶ Update the configuration from an object.
- Parameters
o – the configuration object
-
from_toml
(toml_: pathlib.Path) → elastalk.config.ElastalkConf[source]¶ Update the configuration from a TOML configuration.
- Parameters
toml – the path to the file or the TOML configuration string
-
indexes
= None¶ index-specific configurations
-
mapping_field_limit
= 1000¶ the maximum number of mapped fields
-
maxsize
= 10¶ the maximum number of connections
-
seeds
= None¶ the Elasticsearch seed hosts
-
sniff_on_connection_fail
= True¶ Sniff when the connection fails?
-
sniff_on_start
= True¶ Start sniffing on startup?
-
sniffer_timeout
= 60¶ the sniffer timeout
-
-
exception
elastalk.config.
ElastalkConfigException
[source]¶ Bases:
Exception
Raised when a configuration error is detected.
-
class
elastalk.config.
IndexConf
(blobs: elastalk.config.BlobConf = BlobConf(enabled=None, excluded=set(), key=None), mappings: str = None)[source]¶ Bases:
object
Define index-specific configuration settings.
-
__init__
(blobs: elastalk.config.BlobConf = BlobConf(enabled=None, excluded=set(), key=None), mappings: str = None) → None¶
-
blobs
= BlobConf(enabled=None, excluded=set(), key=None)¶ blobbing configuration for the index
-
classmethod
load
(dict_: Dict) → elastalk.config.IndexConf[source]¶ Create an instance of the class from a dictionary.
- Parameters
dict – the dictionary
- Returns
the instance
-
mappings
= None¶ the path to Elasticsearch mappings for the configuration
-
elastalk.connect¶
Start a conversation with Elasticsearch!
-
class
elastalk.connect.
ElastalkConnection
(config: elastalk.config.ElastalkConf = None)[source]¶ Bases:
object
Defines an Elasticsearch environment.
-
__init__
(config: elastalk.config.ElastalkConf = None)[source]¶ - Parameters
config – the configuration
-
property
client
¶ Get the Elasticsearch client.
- Returns
the Elasticsearch client
- Raises
ElasticsearchConfigurationException – if there is an error in the current configuration
-
property
config
¶ Get the connection configuration.
- Returns
the connection configuration
-
static
default
(cnx: Optional[elastalk.connect.ElastalkConnection] = None) → elastalk.connect.ElastalkConnection[source]¶ Set and/or retrieve the default connection object.
- Parameters
cnx – Provide a new connection object if you want to change the default. Otherwise, leave this argument out to retrieve the current object.
- Returns
the default connection object
-
elastalk.seed¶
Prepare your Elasticsearch store with seed data!
-
elastalk.seed.
seed
(root: str, config: str = 'config.toml', force: bool = False)[source]¶ Populate an Elasticsearch instance with seed data.
- Parameters
root – the root directory that contains the seed data
config – the path to the configuration
force – delete existing indexes and replace them with seed data
- Raises
FileNotFoundError – if the path does not exist
NotADirectoryError – if the path is not a directory
elastalk.version¶
This module contains project version information.