dhavalkapil / elasticsearch-lua Goto Github PK
View Code? Open in Web Editor NEWLua client for Elasticsearch
Home Page: http://elasticsearch-lua.readthedocs.io/
License: MIT License
Lua client for Elasticsearch
Home Page: http://elasticsearch-lua.readthedocs.io/
License: MIT License
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.
The client should handle all kinds of errors and exit gracefully.
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
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
}
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)
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
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
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.
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 ?
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
The performance of the client should be compared with other official clients.
If yes, I am using 5.5.1 and creating index is hanging from some reason.Can you please test it at your side.
In case of a successful request, return parameters should be:
data, status_code
In case of an error, return parameters should be:
nil, message, status_code
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.
Add to the documentation which is the elasticsearch version that the library is currently built on.
Apart from the documentation generated by ldoc
, it is important that proper guides be written.
It seems the client don't support authentication.....
Extensive unit testing for all endpoints is needed. (Tests are already present for the rest of the codebase)
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.