{"id":22588708,"url":"https://github.com/jiawei397/deno_es","last_synced_at":"2025-04-10T21:34:36.452Z","repository":{"id":57675526,"uuid":"378352393","full_name":"jiawei397/deno_es","owner":"jiawei397","description":"deno elasticsearch","archived":false,"fork":false,"pushed_at":"2023-10-11T06:07:04.000Z","size":79,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T19:04:44.280Z","etag":null,"topics":["deno","elastic","elasticsearch","elasticsearch-client","es"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/jiawei397.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-06-19T07:32:44.000Z","updated_at":"2024-06-15T07:40:42.000Z","dependencies_parsed_at":"2024-11-17T12:43:05.541Z","dependency_job_id":"b6aa55f6-5a48-4afc-bae5-f478e9c0ae55","html_url":"https://github.com/jiawei397/deno_es","commit_stats":{"total_commits":87,"total_committers":1,"mean_commits":87.0,"dds":0.0,"last_synced_commit":"b8daf2e806be9de2d3611665815431858a6a9702"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiawei397%2Fdeno_es","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiawei397%2Fdeno_es/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiawei397%2Fdeno_es/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiawei397%2Fdeno_es/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiawei397","download_url":"https://codeload.github.com/jiawei397/deno_es/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103906,"owners_count":21048246,"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":["deno","elastic","elasticsearch","elasticsearch-client","es"],"created_at":"2024-12-08T08:10:34.007Z","updated_at":"2025-04-10T21:34:36.420Z","avatar_url":"https://github.com/jiawei397.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deno_es\n\n\u003e **deno_es** is a **Elastic Search** database driver developed for Deno\n\n## Examples\n\n```ts\nimport { Client } from \"https://deno.land/x/deno_es@v0.5.1/mod.ts\";\nimport Mock from \"https://deno.land/x/deno_mock@v2.0.0/mod.ts\";\n\nconst client = new Client();\n// await client.connect(\"http://elastic:pwd@localhost:9200/\"); // with password\nawait client.connect(\"http://localhost:9200/\");\n\nconst count = async () =\u003e {\n  try {\n    const info: any = await client.count({\n      index: \"myindex\",\n      method: \"post\",\n    });\n    console.info(\"count\", info.count);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst create = async () =\u003e {\n  try {\n    // const id = v4.generate();\n    const info = await client.create({\n      index: \"myindex\",\n      // id,\n      body: Mock.mock({\n        \"email\": \"@EMAIL\",\n        \"name\": \"@NAME\",\n      }),\n    });\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst update = async () =\u003e {\n  try {\n    const info = await client.update({\n      index: \"myindex\",\n      id: 1,\n      body: Mock.mock({\n        \"email\": \"@EMAIL\",\n        \"name\": \"@NAME\",\n      }),\n    });\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst index = async () =\u003e {\n  try {\n    const info = await client.index({\n      index: \"myindex\",\n      id: \"AUA9wn0BCqCFQFsiKm3G\", // if no id , it will create one\n      body: {\n        \"title\": \"hello\",\n        \"content\": \"world\",\n      },\n    });\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst updateByQuery = async () =\u003e {\n  try {\n    // const info = await client.updateByQuery({\n    //   index: \"myindex\",\n    //   body: {\n    //     query: {\n    //       match: {\n    //         name: \"Richard Hall\",\n    //       },\n    //     },\n    //     \"script\": {\n    //       \"source\": 'ctx._source.message = \"updated\"',\n    //     },\n    //   },\n    // });\n    const info = await client.updateByQuery({\n      index: \"myindex\",\n      query: {\n        name: \"Richard Hall\",\n      },\n      script: {\n        source: 'ctx._source.message = \"updated2\"',\n      },\n    });\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst deleteById = async () =\u003e {\n  try {\n    const info = await client.delete({\n      index: \"myindex\",\n      id: 1,\n    });\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst createIndex = async () =\u003e {\n  try {\n    const info = await client.indices.create({\n      index: \"myindex\",\n      // body: {},\n      body: {\n        \"mappings\": {\n          \"properties\": {\n            \"message\": {\n              \"type\": \"text\",\n            },\n            \"query\": {\n              \"type\": \"percolator\",\n            },\n          },\n        },\n      },\n    });\n    console.log(\"createIndex success\", info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst deleteByIndex = async () =\u003e {\n  try {\n    const info = await client.deleteByIndex(\"myindex\");\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst deleteByQuery = async () =\u003e {\n  try {\n    const info = await client.deleteByQuery({\n      index: \"myindex\",\n      body: {\n        query: {\n          \"bool\": {\n            \"must\": [{\n              \"query_string\": { \"default_field\": \"email\", \"query\": \"@EMAIL\" },\n            }],\n          },\n        },\n      },\n    });\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst reIndex = async () =\u003e {\n  try {\n    const info = await client.reindex({\n      oldIndex: \"myindex\",\n      newIndex: \"myindex2\",\n    });\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst stat = async () =\u003e {\n  try {\n    const info = await client.indices.stats({\n      // index: \"myindex\",\n    });\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst getAllIndices = async () =\u003e {\n  try {\n    const info = await client.getAllIndices();\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst search = async () =\u003e {\n  try {\n    const info = await client.search({\n      index: \"myindex\",\n      body: {\n        \"query\": {\n          // \"match_phrase\": {\n          \"match\": {\n            \"title\": \"aa\",\n          },\n        },\n      },\n    });\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n\nconst findById = async () =\u003e {\n  try {\n    const info = await client.get({\n      index: \"myindex\",\n      id: \"11\",\n    });\n    console.log(info);\n  } catch (error) {\n    console.error(error);\n  }\n};\n```\n\n## TODO\n\n- [ ] other API from [es](https://github.com/elastic/elasticsearch-js)\n- [ ] use one tcp query, and now is using fetch everytime\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiawei397%2Fdeno_es","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiawei397%2Fdeno_es","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiawei397%2Fdeno_es/lists"}