
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
github.com/dhavalkapil/elasticsearch-lua
A low level client for Elasticsearch written in Lua.
In accordance with other official low level clients, the client accepts associative arrays in the form of lua table as parameters.
Elasticsearch Version | elasticsearch-lua Branch |
---|---|
>= 2.0, < 5.0 | 2.x.y |
elasticsearch-lua
works for lua >= 5.1 version.
It can be installed using luarocks
[sudo] luarocks install elasticsearch
The complete documetation is here.
local elasticsearch = require "elasticsearch"
local client = elasticsearch.client{
hosts = {
{ -- Ignoring any of the following hosts parameters is allowed.
-- The default shall be set
protocol = "http",
host = "localhost",
port = 9200
}
},
-- Optional parameters
params = {
pingTimeout = 2
}
}
-- Will connect to default host/port
local client = elasticsearch.client()
Full list of params
:
pingTimeout
: The timeout of a connection for ping and sniff request. Default is 1.selector
: The type of selection strategy to be used. Default is RoundRobinSelector
.connectionPool
: The type of connection pool to be used. Default is StaticConnectionPool
.connectionPoolSettings
: The connection pool settings,maxRetryCount
: The maximum times to retry if a particular connection fails.logLevel
: The level of logging to be done. Default is warning
.local param1, param2 = client:<func>()
param1
: Stores the data returned or nil
on error
param2
: Stores the HTTP status code on success or the error message on failure
local data, err = client:info()
Everything is represented as a lua table.
local data, err = client:index{
index = "my_index",
type = "my_type",
id = "my_doc",
body = {
my_key = "my_param"
}
}
data, err = client:get{
index = "my_index",
type = "my_type",
id = "my_doc"
}
data, err = client:delete{
index = "my_index",
type = "my_type",
id = "my_doc"
}
You can search a document using either query string:
data, err = client:search{
index = "my_index",
type = "my_type",
q = "my_key:my_param"
}
Or either a request body:
data, err = client:search{
index = "my_index",
type = "my_type",
body = {
query = {
match = {
my_key = "my_param"
}
}
}
}
data, err = client:update{
index = "my_index",
type = "my_type",
id = "my_doc",
body = {
doc = {
my_key = "new_param"
}
}
}
Feel free to file issues and submit pull requests – contributions are welcome. Please try to follow the code style used in the repository.
elasticsearch-lua is licensed under the MIT license.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.