{"id":18440261,"url":"https://github.com/drowzy/ez","last_synced_at":"2025-07-17T07:32:58.545Z","repository":{"id":68391862,"uuid":"91083593","full_name":"drowzy/ez","owner":"drowzy","description":null,"archived":false,"fork":false,"pushed_at":"2018-04-12T20:05:42.000Z","size":131,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T11:14:09.679Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drowzy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-05-12T11:12:36.000Z","updated_at":"2018-04-23T06:48:05.000Z","dependencies_parsed_at":"2023-07-22T02:54:29.435Z","dependency_job_id":null,"html_url":"https://github.com/drowzy/ez","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/drowzy%2Fez","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drowzy%2Fez/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drowzy%2Fez/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drowzy%2Fez/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drowzy","download_url":"https://codeload.github.com/drowzy/ez/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248905552,"owners_count":21181010,"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-11-06T06:29:13.961Z","updated_at":"2025-04-14T15:26:54.133Z","avatar_url":"https://github.com/drowzy.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ez\nA less verbose Elasticsearch DSL\n\n```\n  ___ ____\n / _ \\_  /\n|  __// /\n \\___/___|\n\n\nA less verbose dsl for elasticsearch\n\n\n  ez [FILENAME]\n\n=== flags ===\n\n  [-d Debug]     a `debug` json string with the original Ez query inlined in the\n                 JSON output\n  [-q Query]     Wraps output in a `query` object\n  [-build-info]  print info about this build and exit\n  [-version]     print the version of this build and exit\n  [-help]        print this help text and exit\n                 (alias: -?)\n```\n\n## Building\n### Docker\nThis package defines two `Dockerfiles` one for the compiler service \u0026 one for the cli.\n\n* CLI\nBuilds an ubuntu compatible cli\n```bash\ndocker build -t ez-cli -f Dockerfile.build\ndocker cp ez-cli:/home/opam/ez/_build/default/bin/main.exe ./_build/ez\n```\n* Compiler service\n```bash\ndocker build -t ez-compiler .\ndocker run --rm -p 3000:3000 ez-compiler\n```\n\n### Local\n\nIn order to compile this package, you will need:\n\n* ocaml\n* findlib\n* yojson\n* menhirLib\n* core_kernel\n* cmdliner\n* opium\n\n* Install dependncies:\nThe easiest way is to create a local switch, pin the package and install the dependencies specified in the opam file:\n\n```bash\nopam switch install ez_switch -A 4.04.1\nopam pin add ez . --no-action\nopam install ez --deps-only\n# Jbuilder \u0026 oUnit is required for development so run the deps.sh script to\n# install them\n./deps.sh\n```\n\n* Compile:\n\n```bash\nmake\n```\n\n### Tests\n\n```bash\nmake test\n```\n\nAfter that it's just a matter of running `make test` to run the suite\n\n\n### Installing\n\n```bash\nmake\nmake install\n\n```\n\n### Uninstalling\n```bash\nmake uninstall\n```\n\n## Usage\n\n```bash\n$ ./ez -q 'foo == \"bar\"'\n  { \"query\": { \"term\": { \"foo\": \"bar\" } } }\n```\n### Stdin\n```bash\n$ echo 'foo == \"bar\"' \u003e src.ez\n$ cat src.ez | ./ez -q\n  { \"query\": { \"term\": { \"foo\": \"bar\" } } }\n```\n### File\n```bash\n$ echo 'foo == \"bar\"' \u003e src.ez\n$ ./ez -q src.ez\n  { \"query\": { \"term\": { \"foo\": \"bar\" } } }\n```\n## Syntax reference\nIdentifiers | Description\n--- | ----\nx | Defines a variable x\nx.y.z | Identifier with projection. Projections are treated as normal variables\n\nBase Types | Description\n--- | ---\n123 | Integer\n1.234 | Float\n\"foo\" | String\n\nBoolean logic | Description | Elastic\n------------- | ----------- | -------\nx or y | one or the other | should\nx and y | both | must\nnot x | not |\n( x ) | precedence | N\\A\nx == y | Equals | term\nx != y | Not equals | must_not -\u003e term\nx \u003c y | Less than | lt\nx \u003c= y | Less than or equal to | lteq\nx \u003e y | Greater than | gt\nx \u003e= y | Greater than or equal to | gteq\n\nExpressions | Descriptions | Example\n----------- | ------------ | -------\n`~r\"json\u003e\"`  | The raw expr allows for inserting an arbitrary elastic json expression | `~r\"{\\\"term:\\\" { \\\"foo\\\": 10 }}\"`\n`\u003cid\u003e { expr }` | Creates a nested scope with `id` as the path. and the expr in the block will be a part of the nested query. | `foo { foo.bar == 10 }`\n`\u003cid\u003e in [\u003cvalue\u003e,\u003cvalue\u003e]` | is the identifier value in the array | `foo in [10, 20]`\n\n### Examples\nEz:\n```python\nfoo == 10\n```\nElastic json:\n```json\n{ \"query\": { \"term\": { \"foo\": 10 } } }\n```\nEz:\n```python\nfoo != 10 and bar == 10\n```\nElastic json:\n```json\n{\n  \"query\": {\n    \"bool\": {\n      \"must\": [\n        { \"bool\": { \"must_not\": { \"term\": { \"foo\": 10 } } } },\n        { \"term\": { \"bar\": 10 } }\n      ]\n    }\n  }\n}\n```\nEz:\n```json\nfoo == 10 or bar == \"foo\"\n```\nElastic json:\n```\n{\n  \"query\": {\n    \"bool\": {\n      \"should\": [ { \"term\": { \"foo\": 10 } }, { \"term\": { \"bar\": \"foo\" } } ]\n    }\n  }\n}\n```\n\nEz:\n```python\nfoo.bar == 10\n```\nElastic json:\n```json\n{ \"query\": { \"term\": { \"foo.bar\": 10 } } }\n```\n\nEz:\n```python\nfoo { foo.bar == \"bar\" }\n```\nElastic json:\n```json\n{\n  \"query\": {\n    \"nested\": { \"path\": \"foo\", \"query\": { \"term\": { \"foo.bar\": \"bar\" } } }\n  }\n}\n```\nEz:\n```python\nfoo in [\"bar\", \"baz\"]\n```\nElastic json:\n```json\n{\n  \"query\": {\n    \"terms\": {\n      \"foo\": [\n        \"bar\",\n        \"baz\"\n      ]\n    }\n  }\n}\n```\n\nEz:\n```python\n(foo { foo.bar == 10 and foo.baz == \"biz\" } and bar.baz \u003c= 10) or biz == \"hw\"\n```\n\nElastic json:\n```json\n{\n  \"query\": {\n    \"bool\": {\n      \"should\": [\n        {\n          \"bool\": {\n            \"must\": [\n              {\n                \"nested\": {\n                  \"path\": \"foo\",\n                  \"query\": {\n                    \"bool\": {\n                      \"must\": [\n                        { \"term\": { \"foo.bar\": 10 } },\n                        { \"term\": { \"foo.baz\": \"biz\" } }\n                      ]\n                    }\n                  }\n                }\n              },\n              { \"range\": { \"bar.baz\": { \"lteq\": 10 } } }\n            ]\n          }\n        },\n        { \"term\": { \"biz\": \"hw\" } }\n      ]\n    }\n  }\n}\n```\n\nInlining:\n\n```python\n(foo { foo.bar == 10 } and ~r\"{ \\\"term\\\": { \\\"bar\\\": 10 } }\") \u003c- ~r\"{ \\\"source\\\": false, \\\"size\\\": 100 }\"\n```\n```json\n{\n  \"bool\": {\n    \"must\": [\n      {\n        \"nested\": {\n          \"path\": \"foo\",\n          \"query\": {\n            \"term\": {\n              \"foo.bar\": 10\n            }\n          }\n        }\n      },\n      {\n        \"term\": {\n          \"bar\": 10\n        }\n      }\n    ]\n  },\n  \"source\": false,\n  \"size\": 100\n}\n```\n## Compiler service\n\nThe `ez_cs` binary is compiler service over HTTP\n\n## Endpoints\n\n* Compile using json:\n```http\nPUT http://localhost:3000/compile\nContent-Type: application/json\n{\n  \"expr\": \"foo { foo.bar == \\\"baz\\\" }\",\n  \"debug\": true\n}\n```\n* Compile using plain/text\n```http\nPUT http://localhost:4000/compile\nContent-Type: text/plain\nfoo { foo.bar == \"baz\"}\n```\n\n* Compile \u0026 proxy to instance\nThe path needs to be url encoded in order to work properly so\n\n`http://localhost:3000/proxy/localhost:9200/index/type` becomes: `http://localhost:3000/proxy/localhost%3A9200%2Findex%2Ftype`\n\nThe compiler service adds the `_search` part to the provided path\n\n```http\nPUT http://localhost:3000/proxy/localhost%3A9200%2Findex%2Ftype\nContent-Type: application/json\n\n{\n  \"expr\": \"foo { foo.bar == 1004 }\",\n  \"debug\": true\n}\n```\n\nSee `ez_cs --help` for flags \u0026 options\n### Running\n```\n./ez_cs --verbose --debug --port 5000 [3000]\n```\nThe verbose flag will print request/response information to stdout.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrowzy%2Fez","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrowzy%2Fez","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrowzy%2Fez/lists"}