{"id":18008903,"url":"https://github.com/breakroom/snap","last_synced_at":"2025-04-09T06:09:44.923Z","repository":{"id":42452796,"uuid":"325784505","full_name":"breakroom/snap","owner":"breakroom","description":"An Elasticsearch/OpenSearch client for Elixir","archived":false,"fork":false,"pushed_at":"2024-09-30T10:17:23.000Z","size":321,"stargazers_count":74,"open_issues_count":11,"forks_count":28,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-10-30T03:44:25.601Z","etag":null,"topics":["elasticsearch","elasticsearch-client","elixir","opensearch","opensearch-client","search"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/breakroom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2020-12-31T11:20:27.000Z","updated_at":"2024-10-10T16:25:10.000Z","dependencies_parsed_at":"2023-11-11T13:40:30.772Z","dependency_job_id":"bcd11455-023c-4839-bc4d-f2b34f34a1e6","html_url":"https://github.com/breakroom/snap","commit_stats":{"total_commits":139,"total_committers":12,"mean_commits":"11.583333333333334","dds":0.3093525179856115,"last_synced_commit":"be1f2e17d8936290e6e916bd4de89090d7a4f732"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breakroom%2Fsnap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breakroom%2Fsnap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breakroom%2Fsnap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breakroom%2Fsnap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/breakroom","download_url":"https://codeload.github.com/breakroom/snap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"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":["elasticsearch","elasticsearch-client","elixir","opensearch","opensearch-client","search"],"created_at":"2024-10-30T02:07:50.689Z","updated_at":"2025-04-09T06:09:44.907Z","avatar_url":"https://github.com/breakroom.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Snap\n\n[![Hex pm](http://img.shields.io/hexpm/v/snap.svg?style=flat)](https://hex.pm/packages/snap)\n\nSnap is an Elasticsearch/OpenSearch client. It provides a flexible, performant API on\ntop of your Elasticsearch cluster, supporting high level features like\nversioned index management, while also providing a convenient interface into\nlow level operations.\n\nSee the full [API docs](https://hexdocs.pm/snap).\n\n## Features\n\n- Versioned index management with zero-downtime hotswapping (compatible with [`elasticsearch`](https://github.com/danielberkompas/elasticsearch-elixir))\n- Streaming bulk operations\n- Connection pooling\n- Telemetry events\n- High level interface over the [Multi Search API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html)\n\n## Installation\n\nThe package can be installed by adding `snap` to your list of dependencies in\n`mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:snap, \"~\u003e 0.12\"},\n    {:finch, \"~\u003e 0.16\"}, # By default, Snap uses Finch to make HTTP requests\n  ]\nend\n```\n\nSnap supports Elixir 1.16 or later.\n\n## Usage\n\nImplement your own cluster module, similar to an `Ecto.Repo`:\n\n```elixir\ndefmodule MyApp.Cluster do\n  use Snap.Cluster, otp_app: :my_app\nend\n```\n\nConfigure it:\n\n```elixir\nconfig :my_app, MyApp.Cluster,\n  url: \"http://localhost:9200\",\n  username: \"my_username\",\n  password: \"my_password\"\n```\n\nThen wire it into your application supervisor:\n\n```elixir\ndef start(_type, _args) do\n  children = [\n    {MyApp.Cluster, []}\n  ]\n\n  opts = [strategy: :one_for_one, name: MyApp.Supervisor]\n  Supervisor.start_link(children, opts)\nend\n```\n\nNow you can perform operations on your cluster:\n\n```elixir\n{:ok, %{\"count\" =\u003e count}} = MyApp.Cluster.get(\"/my-index/_count\")\n```\n\n## Testing\n\nIf you want to test your app that uses this library, but don't want to have integration tests\nwith a Elasticsearch instance running in you local dev environment,\nyou can mock the responses using a custom HTTP client adapter.\n\nSupposing you are using [mox](https://github.com/dashbitco/mox), you can do something like this:\n\n```elixir\n# in test_helper.exs\nMox.defmock(HTTPClientMock, for: Snap.HTTPClient)\nMox.stub(HTTPClientMock, :child_spec, fn _config -\u003e :skip end)\n\n# in config/test.exs\nconfig :my_app, MyApp.Cluster, http_client_adapter: HTTPClientMock\n\n# in a test file\nMox.expect(HTTPClientMock, :request, fn _cluster, _method, _url, _headers, _body, _opts\n  body = \"{}\" # valid json\n  {:ok, %Snap.HTTPClient.Response{status: 200, headers: [], body: body}}\nend)\n```\n\nSee the [API documentation](https://hexdocs.pm/snap) for more advanced features.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbreakroom%2Fsnap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbreakroom%2Fsnap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbreakroom%2Fsnap/lists"}