{"id":16331375,"url":"https://github.com/midoks/lua-resty-elasticsearch","last_synced_at":"2025-05-15T16:14:00.921Z","repository":{"id":76206971,"uuid":"99987744","full_name":"midoks/lua-resty-elasticsearch","owner":"midoks","description":"lua-resty-elasticsearch","archived":false,"fork":false,"pushed_at":"2017-08-11T07:44:41.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-26T10:42:15.835Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/midoks.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-11T03:26:54.000Z","updated_at":"2023-12-28T07:41:04.000Z","dependencies_parsed_at":"2023-03-11T21:45:20.556Z","dependency_job_id":null,"html_url":"https://github.com/midoks/lua-resty-elasticsearch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midoks%2Flua-resty-elasticsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midoks%2Flua-resty-elasticsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midoks%2Flua-resty-elasticsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midoks%2Flua-resty-elasticsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/midoks","download_url":"https://codeload.github.com/midoks/lua-resty-elasticsearch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239286614,"owners_count":19613754,"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":[],"created_at":"2024-10-10T23:26:49.578Z","updated_at":"2025-02-17T12:21:52.030Z","avatar_url":"https://github.com/midoks.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lua-resty-elasticsearch\n\n* base on [lua-resty-http](https://github.com/pintsized/lua-resty-http)\n* [openresty](https://openresty.org)\n\n# Status\ndevelop\n\n# Features\n\n\n\n# API\n\n* [new](#new)\n* [index](#index)\n* [type](#type)\n* [timeout](#timeout)\n* [create](#create)\n* [drop](#drop)\n* [delete](#delete)\n* [count](#count)\n* [update](#update)\n* [search](#search)\n* [query](#query)\n\n## new\n\n```\nlocal el = elastic:new({\n  { host = \"192.168.0.2\", port = 9200 },\n  { host = \"192.168.0.1\", port = 9200 }\n})\n```\n\n## index\n\n```\nel:index('log_2017-8')\n```\n\n## type\n\n```\nel:type('log')\n```\n\n\n## timeout\n\n```\nel:timeout(500)\n```\n\n\n## create\n\n```\n\nlocal cjson = require \"cjson\"\nlocal elastic = require \"resty.elasticsearch.client\"\n\n\nlocal log_json = {}\nlog_json[\"uri\"]=ngx.var.uri\nlog_json[\"args\"]=ngx.var.args  \nlog_json[\"host\"]=ngx.var.host  \nlog_json[\"request_body\"]=ngx.var.request_body  \nlog_json[\"remote_addr\"] = ngx.var.remote_addr  \nlog_json[\"remote_user\"] = ngx.var.remote_user  \nlog_json[\"time_local\"] = ngx.var.time_local  \nlog_json[\"status\"] = ngx.var.status  \nlog_json[\"body_bytes_sent\"] = ngx.var.body_bytes_sent  \nlog_json[\"http_referer\"] = ngx.var.http_referer  \nlog_json[\"http_user_agent\"] = ngx.var.http_user_agent  \nlog_json[\"http_x_forwarded_for\"] = ngx.var.http_x_forwarded_for\nlog_json[\"upstream_response_time\"] = ngx.var.upstream_response_time\nlog_json[\"request_time\"] = ngx.var.request_time\n\nlocal message = cjson.encode(log_json)\n\nlocal ok, err = el:create(log_json)\nif ok then\n  ngx.say(ok)\nelse \n  ngx.say(err)\nend\n```\n\n\n## drop\n\n```\nlocal ok, err = el:drop()\nif ok then\n  ngx.say(ok)\nelse \n  ngx.say(err)\nend\n\n```\n\n## delete\n\n```\nlocal ok, err = el:delete('AV3Lgivmycrvlts2ikBt')\nif ok then\n  ngx.say(ok)\nelse \n  ngx.say(err)\nend\n```\n\n## count\n\n```\nlocal ok, err = el:count()\nif ok then\n  ngx.say(ok)\nelse \n  ngx.say(err)\nend\n```\n\n## update\n\n```\nlocal ok, err = el:update('AV3Lgin5ycrvlts2ikBs',log_json)\nif ok then\n  ngx.say(ok)\nelse \n  ngx.say(err)\nend\n\n```\n\n## search\n\n```\nlocal ok, err = el:search({\n   query = {\n      term = {\n      host = \"127.0.0.1\"\n    }\n  }\n})\nif ok then\n  ngx.say(ok)\nelse \n  ngx.say(err)\nend\n```\n\n## query\n\n```\nlocal ok, err = el:query(\"time_local:2017\")\nif ok then\n  ngx.say(ok)\nelse \n  ngx.say(err)\nend\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidoks%2Flua-resty-elasticsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmidoks%2Flua-resty-elasticsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidoks%2Flua-resty-elasticsearch/lists"}