• Stars
    star
    150
  • Rank 247,323 (Top 5 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lua client for Elasticsearch

elasticsearch-lua

Build Status Coverage Status

Join the chat at https://gitter.im/DhavalKapil/elasticsearch-lua License

LuaRocks 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.

Features:

  1. One-to-one mapping with REST API and other language clients.
  2. Proper load balancing across all nodes.
  3. Pluggable and multiple connection, selection strategies and connection pool.
  4. Console logging facility.
  5. Almost every parameter is configurable.

Elasticsearch Version Matrix

Elasticsearch Version elasticsearch-lua Branch
>= 2.0, < 5.0 2.x.y

Lua Version Requirements

elasticsearch-lua works for lua >= 5.1 version.

Setup

It can be installed using luarocks

  [sudo] luarocks install elasticsearch

Documentation

The 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 params:

  1. pingTimeout : The timeout of a connection for ping and sniff request. Default is 1.
  2. selector : The type of selection strategy to be used. Default is RoundRobinSelector.
  3. connectionPool : The type of connection pool to be used. Default is StaticConnectionPool.
  4. connectionPoolSettings : The connection pool settings,
  5. maxRetryCount : The maximum times to retry if a particular connection fails.
  6. logLevel : The level of logging to be done. Default is warning.

Standard call

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

Getting info of elasticsearch server

local data, err = client:info()

Index a document

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"
  }
}

Get a document

data, err = client:get{
  index = "my_index",
  type = "my_type",
  id = "my_doc"
}

Delete a document

data, err = client:delete{
  index = "my_index",
  type = "my_type",
  id = "my_doc"
}

Searching a document

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"
      }
    }
  }
}

Update a document

data, err = client:update{
  index = "my_index",
  type = "my_type",
  id = "my_doc",
  body = {
    doc = {
      my_key = "new_param"
    }
  }
}

Contribution

Feel free to file issues and submit pull requests – contributions are welcome. Please try to follow the code style used in the repository.

License

elasticsearch-lua is licensed under the MIT license.

More Repositories

1

icmptunnel

Transparently tunnel your IP traffic through ICMP echo and reply packets.
C
3,093
star
2

heap-exploitation

This book on heap exploitation is a guide to understanding the internals of glibc's heap and various attacks possible on the heap structure.
C
1,241
star
3

luaver

Lua Version Manager - Managing and switching between different versions of Lua, LuaJIT and Luarocks made easy
Shell
267
star
4

libdheap

A shared (dynamic) library that can be transparently injected into different processes to detect memory corruption in glibc heap
C
166
star
5

image-uploader

A simple and elegant PHP library for securely uploading images
PHP
62
star
6

dns-validator

Security tool to detect dns poisoning attacks
JavaScript
48
star
7

network-monitor

Tool to analyze and monitor network traffic
JavaScript
44
star
8

stack-guard

A toy implementation of 'Stack Guard' on top of the LLVM compiler toolchain
C++
24
star
9

ctf-writeups

Python
21
star
10

MusicComposer

A music generator that makes pleasing music based on western music theory
Java
12
star
11

dhavalkapil.github.io

My Jekyll Blog website
CSS
9
star
12

viewer

A client/server java application to transmit changes on files on the client side to the server side immediately.
Java
9
star
13

exploits

Java
8
star
14

xss-auditor-analysis

Python
7
star
15

harley

Daily activity center for autistic children developed for Microsoft Code.Fun.Do
C#
5
star
16

FileTransferer

A socket based program to send a file over the network after dividing it into parts and sending each part separately
Java
4
star
17

pwnfox-gdb

Python
4
star
18

digit-recognition

MNIST handwritten digit recognition using Deep Learning
Python
2
star
19

pwnfox-js

JavaScript
2
star
20

Chat

A chatting software implemented in java
2
star
21

arp-analysis

Python
2
star
22

Captcha

An image based customizable CAPTCHA generator written in PHP.
PHP
1
star
23

arp-simulations

Java
1
star
24

IITRVirusRemover

A simple program to remove a particular type of virus found in computers of ICC in IIT Roorkee
Java
1
star
25

ForwardingServer

A server program that accepts input from one client and forwards it to all the clients connected to it
1
star