{"id":13429657,"url":"https://github.com/Ragmaanir/soegen","last_synced_at":"2025-03-16T03:32:05.060Z","repository":{"id":136218350,"uuid":"45354426","full_name":"Ragmaanir/soegen","owner":"Ragmaanir","description":"Elasticsearch client library for crystal, similar to rubys stretcher gem","archived":true,"fork":false,"pushed_at":"2020-11-23T01:58:39.000Z","size":53,"stargazers_count":20,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T23:27:20.765Z","etag":null,"topics":["crystal","elasticsearch-client"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/Ragmaanir.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-11-01T19:34:22.000Z","updated_at":"2023-10-03T01:00:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"a9b92e56-6e8d-4756-900d-1ae68f64fec9","html_url":"https://github.com/Ragmaanir/soegen","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fsoegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fsoegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fsoegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fsoegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ragmaanir","download_url":"https://codeload.github.com/Ragmaanir/soegen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243822310,"owners_count":20353496,"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":["crystal","elasticsearch-client"],"created_at":"2024-07-31T02:00:43.302Z","updated_at":"2025-03-16T03:32:04.516Z","avatar_url":"https://github.com/Ragmaanir.png","language":"Crystal","funding_links":[],"categories":["Search"],"sub_categories":[],"readme":"# soegen [![Build Status](https://travis-ci.org/Ragmaanir/soegen.svg?branch=master)](https://travis-ci.org/Ragmaanir/soegen)[![Dependency Status](https://shards.rocks/badge/github/ragmaanir/soegen/status.svg)](https://shards.rocks/github/ragmaanir/soegen)\n\nElasticSearch client for crystal based on the Stretcher gem for ruby.\n\n### Version 0.12.0\n\n## Compatibility\n\nTests pass with crystal 0.24.0 and ES 5.0.1.\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  soegen:\n    github: ragmaanir/soegen\n    version: ~\u003e 0.12.0\n```\n\nAnd then do:\n\n```crystal\nrequire \"soegen\"\n```\n\n## Usage\n\n```crystal\nrequire \"../spec_helper\"\n\ndescribe Example do\n  test \"basic setup\" do\n    logger = Logger.new(STDOUT)\n    server = Soegen::Server.new(\n      host: \"localhost\",\n      port: ES_PORT, # defaults to localhost:9200\n      ssl: false,\n      read_timeout: (0.5).seconds,\n      connect_timeout: 1.seconds,\n      logger: logger\n    )\n\n    assert server.up?\n    assert server.client.host == \"localhost\"\n    assert server.client.port == ES_PORT\n    assert server.logger == logger\n    assert !server.client.tls?\n\n    idx = server.index(INDEX_NAME)\n\n    assert !idx.exists?\n\n    idx.create\n\n    assert idx.exists?\n\n    t = idx.type(\"events\")\n\n    t.post({data: \"1337\"})\n\n    idx.refresh\n\n    results = t.search({query: {match: {data: \"1337\"}}})\n\n    assert results.total_count == 1\n    assert results.hits.first[\"data\"] == \"1337\"\n  end\n\n  test \"generic request callback\" do\n    requests = [] of {req: Soegen::CompletedRequest, timing: Soegen::Timing}\n    server.define_callback do |req, timing|\n      requests \u003c\u003c {req: req, timing: timing} # you could do your instrumentation here\n    end\n\n    server.up?\n    server.index(INDEX_NAME).create\n\n    assert requests.size == 2\n    assert requests.all? { |pair| pair[:timing].duration \u003c 1.second }\n\n    up_request = requests[0][:req]\n\n    assert up_request.method == \"GET\"\n    assert up_request.path == \"/\"\n    assert up_request.ok_ish?\n\n    create_request = requests[1][:req]\n\n    assert create_request.method == \"PUT\"\n    assert create_request.path == INDEX_NAME\n    assert create_request.ok_ish?\n  end\nend\n\n```\n\n## Testing\n\nThe ES configuration used in the tests is in `\"./spec/config/`:\n\n```yaml\ncluster.name: es_soegen_5_0_0_test # avoid to join other clusters\ncluster.routing.allocation.disk.watermark.low: 500mb\ncluster.routing.allocation.disk.watermark.high: 200mb\n\nnode.name: main_test\nnode.max_local_storage_nodes: 1\n\nhttp.port: ${ES_PORT}\n\ngateway.recover_after_nodes: 1\n\ndiscovery.zen.minimum_master_nodes: 1\ndiscovery.zen.ping.unicast.hosts: []\n\npath.logs: ${SOEGEN_PATH}/temp/elasticsearch/logs\npath.data: ${SOEGEN_PATH}/temp/elasticsearch/data\n\n```\n\nAlso the `spec_helper.cr` configures an index template to set the number of shards and replicas. To run the tests you have to provide your ES executable/command:\n\n```bash\nSOEGEN_ES_CMD=es5 crystal spec\n```\n\nIt then automatically starts the server with the above config.\n\n## TODO\n\n- [x] Indexes and IndexTypes: CRUD\n- [x] Index documents\n- [x] Index documents in bulk\n- [x] Search for documents and return hit array\n- [x] Log requests (as curl commands)\n- [x] General callback for each request (for e.g. instrumentation)\n- [ ] Analyzer API\n- [ ] Alias API\n- [ ] Tests for child documents\n\n## Missing a feature? Found a bug? Need more documentation?\n\nPlease open an issue on this project.\n\n## Contributing\n\n1. Fork it ( https://github.com/ragmaanir/soegen/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Ragmaanir](https://github.com/ragmaanir) - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRagmaanir%2Fsoegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRagmaanir%2Fsoegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRagmaanir%2Fsoegen/lists"}