Code Monkey home page Code Monkey logo

elasticsearch-lua's People

Contributors

criztianix avatar dhavalkapil avatar ignacio avatar kraftman avatar neilcook avatar pmusa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elasticsearch-lua's Issues

Stress Testing

The client should handle all kinds of errors and exit gracefully.

Documentation

Apart from the documentation generated by ldoc, it is important that proper guides be written.

Unit Testing

Extensive unit testing for all endpoints is needed. (Tests are already present for the rest of the codebase)

  • HTTP method needs to be tested for different combinations of parameters
  • HTTP url needs to be tested for different combinations of parameters
  • Adding a Mock Transport class to make this possible, it will intercept the transport's request function and deep check every parameter for correctness.
  • Cover every endpoint

Tests should encompass everything so as to prevent issues like #15. Tests should even check the requests that are made. Checking input/output is not sufficient.

what happened? Msearch.lua

luarocks install --server=http://luarocks.org/manifests/dhavalkapil elasticsearch
Warning: falling back to curl - install luasec to get native HTTPS support
Installing http://luarocks.org/manifests/dhavalkapil/elasticsearch-scm-0.rockspec...
Using http://luarocks.org/manifests/dhavalkapil/elasticsearch-scm-0.rockspec... switching to 'build' mode
Cloning into 'elasticsearch-lua'...
remote: Counting objects: 348, done.
remote: Compressing objects: 100% (190/190), done.
remote: Total 348 (delta 245), reused 215 (delta 154), pack-reused 0
Receiving objects: 100% (348/348), 115.52 KiB | 142.00 KiB/s, done.
Resolving deltas: 100% (245/245), done.
Checking connectivity... done.
stat: cannot stat ‘src/elasticsearch/endpoints/Msearch.lua’: No such file or directory

Error: Build error: Failed installing src/elasticsearch/endpoints/Msearch.lua in /usr/local/openresty/luajit/lib/luarocks/rocks/elasticsearch/scm-0/lua/elasticsearch/endpoints/Msearch.lua

Integration Testing

Apart from testing of every component individually, it is equally important that they work together while interacting with each other.

Some dataset(big one) should be chosen to test. It makes no sense to include the dataset within the repository. Perhaps it would be better to download it from some external source on the fly.

Tests would be layered. Special command line options would allow for different types of testing.

Endpoint "ping" not working

Call to ping return error as it tries to parse body response from HEAD request. Maybe we should verify the "self:getMethod" before decoding the body.

Code to reproduce error:
local es = require"elasticsearch"
local c = es:client()
c:ping()

lua: /usr/local/share/lua/5.3/endpoints/Endpoint.lua:99: Expected value but found T_END at character 1
stack traceback:
[C]: in function 'cjson.decode'
/usr/local/share/lua/5.3/endpoints/Endpoint.lua:99: in function 'endpoints.Endpoint.request'
/usr/local/share/lua/5.3/Client.lua:52: in function 'Client.requestEndpoint'
/usr/local/share/lua/5.3/Client.lua:77: in function 'Client.ping'
es.lua:7: in main chunk
[C]: in ?

Reindex should expect host instead of client.

In order to make it very easy to use we should create and kill the client inside the reindex function.

function helpers.reindex(sourceClient, sourceIndex, targetIndex, query, targetClient, scroll)

Benchmarking

The performance of the client should be compared with other official clients.

bulk operations abort for large sizes

Even though you can construct large bulk bodies, the :bulk API method runs out of memory for large sizes that are well within a bulk operation size. I have records that are approximately 300 bytes each and bulk inserts work okay for 512 insert bodies, but start slowing down drastically at 2048 and somewhere around 4096 start raising "luajit: not enough memory" exceptions.

I'm not sure why this happens, although I assume it's because you're trying to serialize the entire bulk table into the outgoing client JSON TCP stream at the same time rather than generating smaller buffers.

allowParams should be a table and not an array.

Instead of having the following which forces a loop to verify

Scroll.allowedParams = {
  "scroll",
  "scroll_id"
}

we should have the following in which the lookup is direct.

Scroll.allowedParams = {
  "scroll" = true,
  "scroll_id" = true
}

Potential module naming conflicts

Your rockspec defines a bunch of top level modules:

    ["elasticsearch"] = "elasticsearch/elasticsearch.lua",
    ["Settings"] = "elasticsearch/Settings.lua",
    ["Logger"] = "elasticsearch/Logger.lua",
    ["parser"] = "elasticsearch/parser.lua",
    ["helpers"] = "elasticsearch/helpers.lua",
    ["Client"] = "elasticsearch/Client.lua",
    ["Cluster"] = "elasticsearch/Cluster.lua",
    ["Nodes"] = "elasticsearch/Nodes.lua",
    ["Indices"] = "elasticsearch/Indices.lua",
    ["Transport"] = "elasticsearch/Transport.lua",

This means that if I happen to have a file called helpers.lua, or parse.lua, etc. in my project's directory, anytime you call require within your project on one of those modules my code will shadow yours. (This is the case with the default package.path)

You should scope all the modules you install with the name of your project, for example:

    ["elasticsearch"] = "elasticsearch/elasticsearch.lua",
    ["elasticsearch.Settings"] = "elasticsearch/Settings.lua",
    ["elasticsearch.Logger"] = "elasticsearch/Logger.lua",
    ["elasticsearch.parser"] = "elasticsearch/parser.lua",
    ["elasticsearch.helpers"] = "elasticsearch/helpers.lua",
    -- etc

And you'll also need to update the require calls in your code.

luarocks install elasticsearch not working

I tried installing Elastic search using the command luarocks install elasticsearch, but every time I got this error
"luarocks install elasticsearch

Installing http://luarocks.org/repositories/rocks/elasticsearch-1.0.0-1.src.rock...

Missing dependencies for elasticsearch:
lua-cjson

cl /MD /O2 -c -Folua_cjson.obj -IC:/Program Files (x86)/Lua/5.1/include lua_cjson.c -DDISABLE_INVALID_NUMBERS -DUSE_INTERNAL_ISINF
'cl' is not recognized as an internal or external command,
operable program or batch file.

Error: Failed installing dependency: http://luarocks.org/repositories/rocks/lua-cjson-2.1.0.6-1.src.rock - Build error: Failed compiling object lua_cjson.obj
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
"
I tried installing the missing dependency using "luarocks install lua-cjson" but it could not install the dependency. @pmusa @DhavalKapil

install error

luarocks install --server=http://luarocks.org/dev elasticsearch

cp: cannot stat `src/elasticsearch/Cat.lua': No such file or directory
Error: Build error: Failed installing src/elasticsearch/Cat.lua in /usr/lib/luarocks/rocks/elasticsearch/scm-0/lua/elasticsearch/Cat.lua

'params' are not cleared between different client requests

es = require "elasticsearch"

c = es.client({ params = { logLevel = 'trace'}})

c:search({ scroll = '1m', body = { query = {match_all = {}} } })
c:get({ index = 'stack', type = 'question', id = 'a'})

The last get request is something like GET stack/question/a?scroll=1m

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.