{"id":15405697,"url":"https://github.com/zverok/lastic","last_synced_at":"2025-04-14T10:52:24.790Z","repository":{"id":136288755,"uuid":"40252867","full_name":"zverok/lastic","owner":"zverok","description":"ElasticSearch DSL which erases all the complexity","archived":false,"fork":false,"pushed_at":"2016-03-22T17:30:56.000Z","size":44,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T00:06:10.556Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/zverok.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":"2015-08-05T15:20:09.000Z","updated_at":"2018-02-26T01:30:08.000Z","dependencies_parsed_at":"2023-04-09T03:35:27.832Z","dependency_job_id":null,"html_url":"https://github.com/zverok/lastic","commit_stats":{"total_commits":37,"total_committers":2,"mean_commits":18.5,"dds":"0.027027027027026973","last_synced_commit":"576d2e4723c855b76d5603a6f30a65b50860c6cc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Flastic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Flastic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Flastic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Flastic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zverok","download_url":"https://codeload.github.com/zverok/lastic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868816,"owners_count":21174754,"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-10-01T16:18:17.505Z","updated_at":"2025-04-14T10:52:24.765Z","avatar_url":"https://github.com/zverok.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lastic\n\n**UNRELEASED YET. EARLY STAGES**\n\n**Lastic** is an attempt to create not sucking DSL for querying\nElasticSearch from Ruby. It wants to erase complexity and enforce\nreadability and maintainability of the code.\n\nLastic (Ластик) means \"rubber eraser\" in Russian; so its a multi-level\npun on Elastic.\n\nLook and feel:\n\n```ruby\nrequire 'lastic'\ninclude Lastic\n\nLastic.request.\n  query_string('Pride AND prejustice').\n  filter(field('author.name').nested =\u003e 'Jane Osten').\n  from(10..20).\n  sort(field('publications.year').desc).\n  to_h\n# =\u003e really long hash, which is correct ElasticSearch request you can\n#    further pass to any ES client you prefer\n```\n\n## Design goals and features\n\n* Lastic tries to look _natural without explanation_;\n* Lastic tries to be a thin wrapper, with terminological equality with\n  ES API and clean distinction of keywords from params;\n* It also adds convinience tricks and shortcuts here and there (fun we love);\n* It tries to help creating error-prone queries, correct by design;\n* It tries to make query creation chainable, so you can split it to several\n  aspects, and say `request.query(myfield: 'value)` here and add\n  `request.query(otherfield: 'othervalue')` there.\n\nFor most of filter/query types, Lastic enforces `field =\u003e condition` order:\n\nFor example: ES Range query in JSON:\n\n```json\n{\n  \"range\" : {\n    \"age\" : {\n      \"gte\" : 10,\n      \"lte\" : 20,\n    }\n  }\n}\n```\n\nSame condition in Lastic:\n\n```ruby\n# most verbose form\nfield(:age).range(gte: 10, lte: 20)\n\n# short and clean form, in context of request:\nrequest.query(age: (10..20))\n```\n\nTODO: more to write here!\n\n**Caution!**\n* We use ElasticSearch for a limited set of tasks. This design works for\n  them. Maybe for yours it will not at all.\n* Lastic is in early stages of development and it is definitely NOT feature-\n  complete, though targeting it.\n\n## Usage\n\n**HIGHLY INCOMPLETE**\n\n### Aggregations\n\n```ruby\n# ...\n# simple\nrequest.aggs(platforms: Aggs.terms(field: 'platform.id'))\n\n# can be unnamed: Lastic generates the name for you\nrequest.aggs(Aggs.terms(field: 'platform.id'))\n\n# with sub-aggregations:\nrequest.aggs(platforms: Aggs.terms(field: 'platform.id').aggs(sample: Aggs.top_hits(size: 1)))\n\n# can be chained:\nrequest.\n  aggs(Aggs.terms(field: 'platform.id')).\n  aggs(Aggs.avg(field: 'weight')\n# now request have two separate aggregations\n\n# any aggregation can be updated:\nrequest = request.aggs(platforms: Aggs.terms(field: 'platform.id'))\nrequest.aggs[:platforms].aggs!(sample: Aggs.top_hits(size: 1))\n# now \"platforms\" aggregation have \"sample\" sub-aggregation\n\n# possible further improvements: specialized constructors for common aggs:\nrequest.aggs(platforms: Aggs.terms('platform.id')) # without {field: ...}\n```\n\n## Roadmap\n\n* Most of popular ElasticSearch queries, filters, their options and request\n  variants should be implemented;\n* Aggregations should be implemented;\n* There expected to be `Lastic::Search`, which is basically performable\n  request; so, Lastic will became simplistic yet powerful ElasticSearch\n  (read-only) client;\n* `Lastic::Search` (and may be `Lastic::Request` with right setup) will use\n  index's mapping to introspect types and fields, intellectually guess\n  which fields should be nested and how, alert on non-existing (mistyped)\n  fields and so on.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzverok%2Flastic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzverok%2Flastic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzverok%2Flastic/lists"}