{"id":40807855,"url":"https://github.com/ayopop-tech/go-elastic","last_synced_at":"2026-01-21T21:10:05.791Z","repository":{"id":57596528,"uuid":"211008851","full_name":"ayopop-tech/go-elastic","owner":"ayopop-tech","description":"ElasticSearch API for Golang","archived":false,"fork":false,"pushed_at":"2019-10-08T06:09:22.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-20T12:46:18.241Z","etag":null,"topics":["elasticsearch","elasticsearch-client","elasticsearch-plugin","golang","golang-package","logging"],"latest_commit_sha":null,"homepage":"","language":"Go","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/ayopop-tech.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}},"created_at":"2019-09-26T05:42:28.000Z","updated_at":"2019-10-08T06:08:52.000Z","dependencies_parsed_at":"2022-09-26T19:53:09.943Z","dependency_job_id":null,"html_url":"https://github.com/ayopop-tech/go-elastic","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/ayopop-tech/go-elastic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayopop-tech%2Fgo-elastic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayopop-tech%2Fgo-elastic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayopop-tech%2Fgo-elastic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayopop-tech%2Fgo-elastic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayopop-tech","download_url":"https://codeload.github.com/ayopop-tech/go-elastic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayopop-tech%2Fgo-elastic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28642945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T18:04:35.752Z","status":"ssl_error","status_checked_at":"2026-01-21T18:03:55.054Z","response_time":86,"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":["elasticsearch","elasticsearch-client","elasticsearch-plugin","golang","golang-package","logging"],"created_at":"2026-01-21T21:10:04.927Z","updated_at":"2026-01-21T21:10:05.775Z","avatar_url":"https://github.com/ayopop-tech.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## What is `go-elastic`?\n\n`go-elastic` is a library to work with Elasticsearch which allows you to create a client, manipulate information in elasticsearch.\n\n\n## Usage/examples:\nYou can refer to the example below:\n\n```golang\n\npackage main\n\nimport (\n\t\"github.com/ayopop-tech/go-elastic\"\n)\n\nfunc main() {\n\n\tesClient := elastic.NewClient(\"http\", \"localhost\", \"9200\", \"\", \"\")\n\n\tuserId := \"1\"\n\tarticleId := \"22\"\n\tarticleStatus := \"published\"\n\tpublishedAt := \"2019-02-02 11:55:23\"\n\tfilteredDate := strings.Replace(strings.Replace(publishedAt, \":\", \"\", -1), \" \", \"\", -1)\n\tmaxResult := 50\n\n\tindexName := filteredDate + \"_\" + userId + \"_\" + articleStatus\n\n\tresp2, err := esClient.IndexExists(indexName)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n\tif !resp2 {\n\t\t_, err := esClient.CreateIndex(indexName, \"\")\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t}\n\n\tdata := map[string]string{\n\t\t\"tid\":            articleId,\n\t\t\"current_status\": articleStatus,\n\t\t\"time\":           publishedAt,\n\t}\n\n\tmarshalledData, _ := json.Marshal(data)\n\n\t_, err = esClient.InsertDocument(indexName, articleId, marshalledData)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n\tsearchResults, err := esClient.FindDocuments(indexName, articleId, maxResult)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n}\n```\n\n### For bulk insert:\n\n```\ngolang \n\n// First create bulk data\nbulkInsertData := [...]Product{\n    Product{Name: \"Jeans\", Colors: []string{\"blue\", \"red\"}},\n    Product{Name: \"Polo\", Colors: []string{\"yellow\", \"red\"}},\n    Product{Name: \"Shirt\", Colors: []string{\"brown\", \"blue\"}},\n}\n\n// Transform it into bulk data needed as per elasticsearch\nbulkProduct := make([]interface{}, len(bulkInsertData))\nfor i := range bulkInsertData {\n    bulkProduct[i] = bulkInsertData[i]\n}\n\nfor _, value := range bulkProduct {\n    buffer.WriteString(BulkIndexConstant(\"your-index-name\", \"your-document-type\"))\n    buffer.WriteByte('\\n')\n\n    jsonProduct, _ := json.Marshal(value)\n    buffer.Write(jsonProduct)\n    buffer.WriteByte('\\n')\n}\n\n// Send request to client\n_, err := esClient.BulkInsert(buffer.Bytes())\nif err != nil {\n    fmt.Println(err.Error())\n}\n\n``` \n\n## Contributing\n\n1. Create an issue, describe the bugfix/feature you wish to implement.\n2. Fork the repository\n3. Create your feature branch (`git checkout -b my-new-feature`)\n4. Commit your changes (`git commit -am 'Add some feature'`)\n5. Push to the branch (`git push origin my-new-feature`)\n6. Create a new Pull Request","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayopop-tech%2Fgo-elastic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayopop-tech%2Fgo-elastic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayopop-tech%2Fgo-elastic/lists"}