maggienj / ActiveData

Provide high speed filtering and aggregation over data
Mozilla Public License 2.0
0 stars 0 forks source link

how to write a select query in activedata to list all tables/indices #63

Open maggienj opened 7 years ago

maggienj commented 7 years ago

This doc shows how to write a select query if the table/index name is known. https://github.com/klahnakoski/ActiveData/blob/dev/docs/jx_tutorial.md

{"from": "unittest"} will list all docs from unittest.

but, just curious... how to list all available indices or tables which a user could query upon ?

klahnakoski commented 7 years ago

For a list of tables:

{"from":"meta.tables","limit":1000}

For columns:

{
    "from":"meta.columns",
    "limit":1000,
    "where":{"eq":{"table":"unittest.run.files"}}
}

notice the table name; unfortunately not listed in the meta.tables, but is listed with the columns.

maggienj commented 7 years ago

wow.

as a followup q.... meta.tables meta.columns meta. ? meta. ? what other meta. exists?
I might have missed the doc where the meta.(dot) is.... (if a doc exists for the activedata-meta.... please direct me there )

klahnakoski commented 7 years ago

You may recall working on jx_elasticsearch.meta.py where those two tables are filled in with the count and cardinalilty information. There are no others in the meta namespace, and even these tables are not fully featured: They can not handle general queries because they are not actual tables and they are not in ES.

lmilton-ithaka commented 7 years ago

When I run {"from": "unittest"}, I get an error. I am in typed branch and using the following config to start appdev.

--settings=tests/es5/maggie_config.json

Call to ActiveData failed File ESQueryRunner.js, line 33, in ActiveDataQuery File thread.js, line 247, in Thread_prototype_resume [as resume] File thread.js, line 226, in retval File Rest.js, line 46, in Object.ajaxParam.error File Rest.js, line 100, in XMLHttpRequest.request.onreadystatechange caused by Error while calling /query caused by Bad response (400) caused by No index by name of unittest File elasticsearch.py, line 976, in init File init.py, line 62, in wrapper File jx_usingES.py, line 75, in init File init.py, line 66, in wrapper File init.py, line 98, in wrap_from File jx.py, line 61, in jx_query File init.py, line 54, in output File app.py, line 1598, in dispatch_request File app.py, line 1612, in full_dispatch_request File app.py, line 1982, in wsgi_app File app.py, line 1997, in call File serving.py, line 197, in execute File serving.py, line 209, in run_wsgi File serving.py, line 267, in handle_one_request File BaseHTTPServer.py, line 340, in handle File serving.py, line 232, in handle File SocketServer.py, line 655, in init File SocketServer.py, line 334, in finish_request File SocketServer.py, line 599, in process_request_thread File threading.py, line 763, in run File threading.py, line 810, in __bootstrap_inner File threading.py, line 783, in __bootstrap

klahnakoski commented 7 years ago

ActiveData can be used to query ES indexes. A unittest index is found in Mozilla's ES cluster, so Mozilla's ActiveData instance can query it

curl http://activedata.allizom.org/query -d "{\"from\": \"unittest\"}"

Your instance of ActiveData is using your ES cluster. As it says in the error, your ES cluster does not have a unittest index:

caused by No index by name of unittest
lmilton-ithaka commented 7 years ago

Ok, great. I am now able to run the queries in the JSON Query Tutorial document.

image

lmilton-ithaka commented 7 years ago

Jobs Schema: image

lmilton-ithaka commented 7 years ago

curl command works as well. Thank you!

lmilton-ithaka commented 7 years ago

These are the indexes in my cluster. I was able to create two indexes in my ES cluster, customer, lavanya-test-index

image

klahnakoski commented 7 years ago

May I assume there is no outstanding question here?