{"id":17995865,"url":"https://github.com/dhavalkapil/elasticsearch-lua","last_synced_at":"2025-03-26T03:32:06.769Z","repository":{"id":29327540,"uuid":"32861129","full_name":"DhavalKapil/elasticsearch-lua","owner":"DhavalKapil","description":"Lua client for Elasticsearch","archived":false,"fork":false,"pushed_at":"2022-06-02T11:24:02.000Z","size":460,"stargazers_count":150,"open_issues_count":6,"forks_count":38,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-21T05:11:58.704Z","etag":null,"topics":["elasticsearch","elasticsearch-lua","lua"],"latest_commit_sha":null,"homepage":"http://elasticsearch-lua.readthedocs.io/","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DhavalKapil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-25T11:46:42.000Z","updated_at":"2024-05-06T22:16:18.000Z","dependencies_parsed_at":"2022-09-14T10:11:47.573Z","dependency_job_id":null,"html_url":"https://github.com/DhavalKapil/elasticsearch-lua","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DhavalKapil%2Felasticsearch-lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DhavalKapil%2Felasticsearch-lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DhavalKapil%2Felasticsearch-lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DhavalKapil%2Felasticsearch-lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DhavalKapil","download_url":"https://codeload.github.com/DhavalKapil/elasticsearch-lua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245585298,"owners_count":20639668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elasticsearch","elasticsearch-lua","lua"],"created_at":"2024-10-29T21:11:59.810Z","updated_at":"2025-03-26T03:32:06.297Z","avatar_url":"https://github.com/DhavalKapil.png","language":"Lua","readme":"# elasticsearch-lua \n\n[![Build Status](https://travis-ci.org/DhavalKapil/elasticsearch-lua.svg?branch=2.x.y)](https://travis-ci.org/DhavalKapil/elasticsearch-lua) [![Coverage Status](https://coveralls.io/repos/github/DhavalKapil/elasticsearch-lua/badge.svg?branch=2.x.y)](https://coveralls.io/github/DhavalKapil/elasticsearch-lua?branch=2.x.y)\n\n[![Join the chat at https://gitter.im/DhavalKapil/elasticsearch-lua](https://badges.gitter.im/DhavalKapil/elasticsearch-lua.svg)](https://gitter.im/DhavalKapil/elasticsearch-lua?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge) [![License](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)\n\n[![LuaRocks](https://img.shields.io/badge/LuaRocks-2.4.1-blue.svg)](https://luarocks.org/modules/dhavalkapil/elasticsearch) [![Lua](https://img.shields.io/badge/Lua-5.1%2C%20JIT%2C%205.2%2C%205.3-blue.svg)](https://img.shields.io/badge/Lua-5.1%2C%20JIT%2C%205.2%2C%205.3-blue.svg)\n\nA low level client for Elasticsearch written in Lua.\n\nIn accordance with other official low level clients, the client accepts associative arrays in the form of lua table as parameters.\n\n## Features:\n\n1. One-to-one mapping with REST API and other language clients.\n2. Proper load balancing across all nodes.\n3. Pluggable and multiple connection, selection strategies and connection pool.\n4. Console logging facility.\n5. Almost every parameter is configurable.\n\n## Elasticsearch Version Matrix\n\n| Elasticsearch Version | elasticsearch-lua Branch |\n| --------------------- | ------------------------ |\n| \u003e= 2.0, \u003c 5.0         | 2.x.y                    |\n\n## Lua Version Requirements\n\n`elasticsearch-lua` works for lua \u003e= 5.1 version.\n\n## Setup\n\nIt can be installed using [luarocks](https://luarocks.org)\n\n```\n  [sudo] luarocks install elasticsearch\n```\n\n## Documentation\n\nThe complete documetation is [here](http://elasticsearch-lua.readthedocs.io/).\n\n### Create elasticsearch client instance:\n\n```lua\n  local elasticsearch = require \"elasticsearch\"\n\n  local client = elasticsearch.client{\n    hosts = {\n      { -- Ignoring any of the following hosts parameters is allowed.\n        -- The default shall be set\n        protocol = \"http\",\n        host = \"localhost\",\n        port = 9200\n      }\n    },\n    -- Optional parameters\n    params = {\n      pingTimeout = 2\n    }\n  }\n```\n\n```lua\n  -- Will connect to default host/port\n  local client = elasticsearch.client()\n```\n\nFull list of `params`:\n\n1. `pingTimeout` : The timeout of a connection for ping and sniff request. Default is 1.\n2. `selector` : The type of selection strategy to be used. Default is `RoundRobinSelector`.\n3. `connectionPool` : The type of connection pool to be used. Default is `StaticConnectionPool`.\n4. `connectionPoolSettings` : The connection pool settings,\n5. `maxRetryCount` : The maximum times to retry if a particular connection fails.\n6. `logLevel` : The level of logging to be done. Default is `warning`.\n\n### Standard call\n\n```lua\nlocal param1, param2 = client:\u003cfunc\u003e()\n```\n\n`param1`: Stores the data returned or `nil` on error\n\n`param2`: Stores the HTTP status code on success or the error message on failure\n\n### Getting info of elasticsearch server\n\n```lua\nlocal data, err = client:info()\n```\n\n### Index a document\n\nEverything is represented as a lua table.\n\n```lua\nlocal data, err = client:index{\n  index = \"my_index\",\n  type = \"my_type\",\n  id = \"my_doc\",\n  body = {\n    my_key = \"my_param\"\n  }\n}\n```\n\n### Get a document\n\n```lua\ndata, err = client:get{\n  index = \"my_index\",\n  type = \"my_type\",\n  id = \"my_doc\"\n}\n```\n\n### Delete a document\n\n```lua\ndata, err = client:delete{\n  index = \"my_index\",\n  type = \"my_type\",\n  id = \"my_doc\"\n}\n```\n### Searching a document\n\nYou can search a document using either query string:\n\n```lua\ndata, err = client:search{\n  index = \"my_index\",\n  type = \"my_type\",\n  q = \"my_key:my_param\"\n}\n```\n\nOr either a request body:\n\n```lua\ndata, err = client:search{\n  index = \"my_index\",\n  type = \"my_type\",\n  body = {\n    query = {\n      match = {\n        my_key = \"my_param\"\n      }\n    }\n  }\n}\n```\n\n### Update a document\n\n```lua\ndata, err = client:update{\n  index = \"my_index\",\n  type = \"my_type\",\n  id = \"my_doc\",\n  body = {\n    doc = {\n      my_key = \"new_param\"\n    }\n  }\n}\n```\n\n## Contribution\n\nFeel free to [file issues](https://github.com/DhavalKapil/elasticsearch-lua/issues) and submit [pull requests](https://github.com/DhavalKapil/elasticsearch-lua/pulls) – contributions are welcome. Please try to follow the code style used in the repository.\n\n## License\n\nelasticsearch-lua is licensed under the [MIT license](https://dhaval.mit-license.org/2015/license.txt).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhavalkapil%2Felasticsearch-lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhavalkapil%2Felasticsearch-lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhavalkapil%2Felasticsearch-lua/lists"}