Client Configuration¶
elasticsearch-lua was designed to allow users to configure almost all of the parameters. The standard way of creating and configuring the client is:
local client = elasticsearch.client{
hosts = {
-- array of elasticsearch hosts
{
protocol = "http",
host = "localhost",
port = "9200"
}
},
params = {
-- additional parameters to configure the client
pingTimeout = 2,
logLevel = "warn"
}
}
Every configuration passed while creating a client is optional. Default settings are used for configurations that are not provided by the user, as detailed below.
Host Configuration¶
A ‘host‘ refers to a single node of elasticsearch server. It may or may not be part of a cluster. Hosts are specified by using the key hosts. It consists of an array of hosts, wherein each host has 3 parameters:
- protocol : The underlying protocol to be used while communicating with the host. Defaults to ‘http‘. (Presently, the client only supports http)
- host: The domain name or the IP address at which the host is running. Defaults to ‘localhost‘.
- port: The port on which the host is listening. Defaults to ‘9200‘.
Additional Parameters¶
You can also specify some additional parameters to configure the elasticsearch server. Again, these parameters are optional and have default values.
Parameter | Description | Default |
---|---|---|
pingTimeout | The timeout (in seconds) for any ping or sniff HTTP request made by the client to the elasticsearch server |
1 |
requestEngine | The connection request ending to be used. For more details, see Connection. |
‘LuaSocket’ |
selector | The selector to be used. For more details, see |
‘RoundRobinSelector’ |
connectionPool | The connection pool to be used. For more details, see Connection Pool. |
‘StaticConnectionPool’ |
maxRetryCount | The number of times to retry an HTTP request before exiting with a TransportError |
5 |
logLevel | The level of the inbuilt console logger. Follows the convention of log4j: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN. (ignores case) |
‘WARN’ |