{"id":37112208,"url":"https://github.com/han2015/esql","last_synced_at":"2026-01-14T13:16:49.644Z","repository":{"id":57551865,"uuid":"163721223","full_name":"han2015/esql","owner":"han2015","description":"lightweight ORM tool of elasticsearch for go, no third dependence. ","archived":false,"fork":false,"pushed_at":"2019-06-14T15:21:46.000Z","size":41,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-03T00:06:55.746Z","etag":null,"topics":["api","elastic","elasticsearch","esql","go","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/han2015.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-01T07:38:59.000Z","updated_at":"2022-09-29T14:22:02.000Z","dependencies_parsed_at":"2022-09-26T18:41:38.555Z","dependency_job_id":null,"html_url":"https://github.com/han2015/esql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/han2015/esql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/han2015%2Fesql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/han2015%2Fesql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/han2015%2Fesql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/han2015%2Fesql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/han2015","download_url":"https://codeload.github.com/han2015/esql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/han2015%2Fesql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420955,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api","elastic","elasticsearch","esql","go","sql"],"created_at":"2026-01-14T13:16:49.035Z","updated_at":"2026-01-14T13:16:49.631Z","avatar_url":"https://github.com/han2015.png","language":"Go","readme":"\n## Esql\na ligthwight tool of elasticsearch of go (depend ES6.0). inspired from [gorm](https://github.com/jinzhu/gorm), an ORM database tool.\n\nElasticearch api support json format, and fruitful api with it's specially format to support various search function,\nvery flexible and extendable. But we are difficult to organize so many level conditions manually. \n\nUsually, we prefer to know what the function of this api and how to use it, but not very care how it works.\n\nEsql try to give big convenience on this issues. it wants help you just to concentrate on conditions of API, and \neasy to set conditions.\n\n    e.g. definition: Match(i ...Setting)\n    conditions actually are settings of fields, one field one setting. it allows you set many conditons same time. \n   \n    1. Match(esql.F{\"field\":\"setting\"})\n    \n    2. Match(esql.F{\"field\":\"setting\"},esql.F{\"field2\":\"setting2\"},esql.F{\"field3\":\"setting3\"}) \n    \n\n### Overview\n* Index \n    * IndexExists    \n    * CreateIndex \n    * Delete\n    * ShowMapping\n    * AutoMapping\n    \n* Document crud\n    * GetDocWithID\n    * IndexDoc\n    * UpdateDoc\n    * DeleteDoc\n    * UpdatePartialDoc\n    * AutoIndexDocs\n     \n* Search\n    * Dismax\n    * Where as Match\n    * Not as MustNot\n    * Or as Should\n    * In as Term\n    * Missing\n    * NotNil\n    * Between\n    * Order\n    * Limit\n    * StringQuery\n    * SimpleStringSelect\n    * Phrase\n    * Must\n    * MustNot\n    * Should\n    * Filter\n    * Range\n    * Term\n    * Terms\n    * Regexp\n    * Fuzzy\n    * Wildcard\n    * Scroll\n    * GetScroll\n    * Joins\n    * MatchAll\n    \n* Aggregation\n    * Bucket\n        * Group as GroupTerms\n        * GroupTerms\n        * GroupDateHistogram\n        * GroupHistogram\n        * GroupDateRange\n        * GroupIPRange\n        * GroupRange\n        * GroupGeoDistance\n    * Metric (all)\n        * Avg\n        * Max\n        * Sum\n        * Count\n        * Stats\n        * WeightedAvg\n        * Cardinality\n        * ExtendedStats\n        * GeoBounds\n        * GeoCentroid\n        * Percentiles\n        * PercentileRanks\n\n### Esql tool\n\n* ###### NewElasticSearch: a convenient client tool for glboal.\nit allows you assign a table(index) at first, the following options always work on it.\n```go   \n    es:=esql.NewElasticSearch(\"esql,product,user\"); \n    var s1,s2,s3 []sturct\n    go func(){\n        es.DB().Where(esql.F{\"name\":\"name\"}).Limit(10).Find(\u0026s1)\n    }()\n    \n    go func(){\n        es.DB().Term(esql.F{\"gender\":\"make\"}).Limit(50,100).Count(\"gender\").Find(\u0026s1)\n    }()\n    \n    go func(){\n        es.DB().Range(esql.F{\"age\":esql.F{\"gt\":18}).Find(\u0026s1)\n    }()\n```\n* ###### Condition tool(F \u0026 Not):\n ideally, you just concentrate on conditions of Match. if you have multi conditions, should make F slice.\n\n    __ F __: a alias of map, name form `Find` and a positive action. \n    \n    __ Not __: a alias of map, indicate a negative action. if you use it in __ any __ searching api, it will auto as  __MustNot__ condition.\n    \n    \n### Esql cases:\n```go\n  es:=esql.NewElasticSearch(\"esql\")\n  \n  var aggregation struct\n  var results []struct\n  if err:=es.DB().Where(esq.F{\"name\":\"input my name\"},esq.F{\"age\":18}).\n        Match(esql.F{\"content\":\"input the text\"}).\n        Not(esql.Not{\"name\":\"do want\"}).\n        Or(esql.F{\"should\":\"maybeok\"}).\n        Order(esql.F{\"name\":\"desc\"}).\n        Limit(5).\n        Find(\u0026results).\n        Error;err!=nil{\n            log.Println(err.Error())\n    }\n  \n  if err:=es.DB().Term(esql.F{\"age\":18,\"gender\":\"male\"},esql.F{\"language_code\":\"en-gb\"}).\n        Range(esql.F{\"created_at\":esql.F{\"gt\":\"2015-01-01\",\"lte\":\"2019-01-01\"}}).\n        Group(\"color\").\n        Sum(\"group_color\").\n        Count(\"age\").\n        Find(\u0026aggregation).\n        Error;err!=nil{\n            log.Println(err.Error())\n    }\n       \n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhan2015%2Fesql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhan2015%2Fesql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhan2015%2Fesql/lists"}