在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):DhavalKapil/elasticsearch-lua开源软件地址(OpenSource Url):https://github.com/DhavalKapil/elasticsearch-lua开源编程语言(OpenSource Language):Lua 99.1%开源软件介绍(OpenSource Introduction):elasticsearch-luaA 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. Features:
Elasticsearch Version Matrix
Lua Version Requirements
SetupIt can be installed using luarocks
DocumentationThe complete documetation is here. Create elasticsearch client instance: 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
Standard calllocal param1, param2 = client:<func>()
Getting info of elasticsearch serverlocal data, err = client:info() Index a documentEverything 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"
}
} Get a documentdata, err = client:get{
index = "my_index",
type = "my_type",
id = "my_doc"
} Delete a documentdata, err = client:delete{
index = "my_index",
type = "my_type",
id = "my_doc"
} Searching a documentYou 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"
}
}
}
} Update a documentdata, err = client:update{
index = "my_index",
type = "my_type",
id = "my_doc",
body = {
doc = {
my_key = "new_param"
}
}
} ContributionFeel free to file issues and submit pull requests – contributions are welcome. Please try to follow the code style used in the repository. Licenseelasticsearch-lua is licensed under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论