{"id":27067430,"url":"https://github.com/aparo/zio-opensearch","last_synced_at":"2025-09-13T01:42:12.700Z","repository":{"id":281999188,"uuid":"937314973","full_name":"aparo/zio-opensearch","owner":"aparo","description":"Strong Opinionated OpenSearch Client for Scala Zio","archived":false,"fork":false,"pushed_at":"2025-03-12T08:14:51.000Z","size":4249,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T19:48:55.594Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aparo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-22T20:54:08.000Z","updated_at":"2025-03-12T08:14:54.000Z","dependencies_parsed_at":"2025-03-12T09:35:15.432Z","dependency_job_id":null,"html_url":"https://github.com/aparo/zio-opensearch","commit_stats":null,"previous_names":["aparo/zio-opensearch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aparo/zio-opensearch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aparo%2Fzio-opensearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aparo%2Fzio-opensearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aparo%2Fzio-opensearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aparo%2Fzio-opensearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aparo","download_url":"https://codeload.github.com/aparo/zio-opensearch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aparo%2Fzio-opensearch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274907834,"owners_count":25371819,"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","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-04-05T19:49:06.158Z","updated_at":"2025-09-13T01:42:12.680Z","avatar_url":"https://github.com/aparo.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zio-opensearch\nOpenSearch client for Scala based on ZIO and FP.\nOnly OpenSearch 2.9.x or above are supported.\n\nThe project targets are:\n- simply API for JVM\n- completely functional approach on the library based on ZIO\n- full typesafe Query, Aggregation, Request and Response of OpenSearch\n- http layer based on [sttp](https://github.com/softwaremill/sttp) (in future zio-http when it will be released)\n- using [zio-json]() for json management \n- full coverage of OpenSearch call/responses (generated from API)\n\nAll the code is based on Manager (ZIO Services) that can be composed to provide required functionalities to your project.\nSplitting the API in different reduces the size of the classes for the overall project.\n\nThe actual modules are:\n\n - zio-opensearch-core: it provides all the core functionalities: document management and searching (query, aggregation, ...)\n - zio-opensearch-cluster: it provides support for cluster API\n - zio-opensearch-dangling-indices: it provides support for Dangling Indices API\n - zio-opensearch-enrich: it provides support for Enrich API\n - zio-opensearch-indices: it provides support for Index Management API\n - zio-opensearch-ingest: it provides support for Ingest API with strong typed Process support\n - zio-opensearch-license: it provides support for License API\n - zio-opensearch-logstash: it provides support for Logstash API\n - zio-opensearch-migration: it provides support for Migration API\n - zio-opensearch-ml: it provides support for Machine Learning API\n - zio-opensearch-monitoring: it provides support for Monitoring API\n - zio-opensearch-nodes: it provides support for Nodes API\n - zio-opensearch-rollup: it provides support for Roll Up API\n - zio-opensearch-searchable-snapshots: it provides support for Searchable Snapshot API\n - zio-opensearch-security: it provides support for Security API\n - zio-opensearch-shutdown: it provides support for Shutdown API\n - zio-opensearch-slm: it provides support for SLM API\n - zio-opensearch-snapshot: it provides support for Snapshot API\n - zio-opensearch-sql: it provides support for SQL API\n - zio-opensearch-ssl: it provides support for SSL API\n - zio-opensearch-tasks: it provides support for Tasks API\n - zio-opensearch-text-structure: it provides support for Text Structure API\n - zio-opensearch-transform: it provides support for Transform API\n\nAnd their dependencies are the following ones:\n![Module dependencies](dependencies.png)\n\n\n## Quick usage tour\n\nThe follow overcommented example is taken from test directory:\n\n\n\n```\npackage zio.opensearch.client\n\nimport zio.opensearch.orm.QueryBuilder\nimport zio.opensearch.queries.TermQuery\nimport zio.opensearch.requests.UpdateByQueryRequest\nimport zio.opensearch.{ ESSystemUser, SpecHelper, AuthContext }\nimport zio.json._\nimport io.circe._\nimport org.codelibs.opensearch.runner.OpenSearchClusterRunner\nimport org.scalatest._\nimport zio.blocking.Blocking\nimport org.scalatest.WordSpec\nimport zio.clock.Clock\nimport zio.console.Console\nimport zio.random.Random\nimport zio.{ DefaultRuntime, system }\n\nclass OpenSearchSpec extends WordSpec with Matchers with BeforeAndAfterAll with SpecHelper {\n\n  // we init a cluster for test\n  private val runner = new OpenSearchClusterRunner()\n\n  // we init a n OpenSearch Client\n  implicit val opensearch = ZioClient(\"localhost\", 9201)\n\n  // we need a ZIO Enrvironment to \"runUnsafe\" out code\n  lazy val environment: zio.Runtime[Clock with Console with system.System with Random with Blocking] =\n    new DefaultRuntime {}\n\n  // a context propagate user and other info for every call without need to pass the arguments to all functions\n  implicit val context =\n    new AuthContext(ESSystemUser, opensearch = opensearch)\n\n  // we create a case class that contains our data\n  // JsonCodec is a macro annotation that create encoder and decoder for circe\n  @JsonCodec\n  case class Book(title: String, pages: Int)\n\n\n  // we init the data \n  override def beforeAll() = {\n    runner.build(OpenSearchClusterRunner.newConfigs().baseHttpPort(9200).numOfNode(1))\n    runner.ensureYellow()\n\n    // we prepare he store statement with an ending refresh\n    val load = for {\n      _ \u003c- register(\"source\", \"Akka in Action\", 1)\n      _ \u003c- register(\"source\", \"Programming in Scala\", 2)\n      _ \u003c- register(\"source\", \"Learning Scala\", 3)\n      _ \u003c- register(\"source\", \"Scala for Spark in Production\", 4)\n      _ \u003c- register(\"source\", \"Scala Puzzlers\", 5)\n      _ \u003c- register(\"source\", \"Effective Akka\", 6)\n      _ \u003c- register(\"source\", \"Akka Concurrency\", 7)\n      _ \u003c- opensearch.refresh(\"source\")\n\n    } yield ()\n\n    // we execute the statement with the ZIO environment\n    environment.unsafeRun(load)\n  }\n\n  // called on test completion\n  override def afterAll() = {\n    opensearch.close()\n    runner.close()\n    runner.clean()\n  }\n\n  // helper function to flush ES to allow to search data\n  def flush(indexName: String): Unit =\n    environment.unsafeRun(opensearch.refresh(indexName))\n\n  // helper function to create an index request\n  private def register(indexName: String, title: String, pages: Int) =\n    opensearch.indexDocument(\n      indexName,\n      body = JsonObject.fromMap(\n        Map(\"title\" -\u003e Json.fromString(title), \"pages\" -\u003e Json.fromInt(pages), \"active\" -\u003e Json.fromBoolean(false))\n      )\n    )\n\n  \"Client\" should {\n\n    \"count elements\" in {\n      // we call the countAll elements inside a index\n      val count = environment.unsafeRun(opensearch.countAll(\"source\"))\n      count should be(7)\n    }\n\n    \"update pages\" in {\n      \n      // we call the updateByQuery\n      val multipleResultE = environment.unsafeRun(\n        opensearch.updateByQuery(\n          UpdateByQueryRequest.fromPartialDocument(\"source\", JsonObject(\"active\" -\u003e Json.fromBoolean(true)))\n        )\n      )\n\n      multipleResultE.updated should be(7)\n      flush(\"source\")\n      \n      // we execute a query on updated data\n      val searchResultE = environment.unsafeRun(\n        opensearch.search(QueryBuilder(indices = List(\"source\"), filters = List(TermQuery(\"active\", true))))\n      )\n\n      searchResultE.total.value should be(7)\n    }\n  }\n\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faparo%2Fzio-opensearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faparo%2Fzio-opensearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faparo%2Fzio-opensearch/lists"}