{"id":21731346,"url":"https://github.com/ymm-tech/ebatis","last_synced_at":"2025-04-06T03:10:40.040Z","repository":{"id":41164420,"uuid":"270894686","full_name":"ymm-tech/ebatis","owner":"ymm-tech","description":"ORM Framework for Elasticsearch","archived":false,"fork":false,"pushed_at":"2023-12-05T22:28:19.000Z","size":808,"stargazers_count":233,"open_issues_count":8,"forks_count":64,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-30T02:07:14.782Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/ymm-tech.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":"2020-06-09T03:33:43.000Z","updated_at":"2025-02-12T06:38:57.000Z","dependencies_parsed_at":"2024-12-31T05:12:04.661Z","dependency_job_id":"3b503f4b-db5c-4774-9d84-514507479501","html_url":"https://github.com/ymm-tech/ebatis","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymm-tech%2Febatis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymm-tech%2Febatis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymm-tech%2Febatis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymm-tech%2Febatis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ymm-tech","download_url":"https://codeload.github.com/ymm-tech/ebatis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"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":[],"created_at":"2024-11-26T04:24:16.566Z","updated_at":"2025-04-06T03:10:40.022Z","avatar_url":"https://github.com/ymm-tech.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ebatis是什么\n[![GitHub Stars](https://img.shields.io/badge/stars-100%2B-blue)](https://github.com/ymm-tech/ebatis/stargazers) \n[![JDK support](https://img.shields.io/badge/JDK-8+-green.svg)](https://github.com/ymm-tech/ebatis/releases)\n[![Maven Central](https://img.shields.io/badge/maven-7.5.1.4.RELEASE-green)](https://search.maven.org/search?q=ebatis)\n[![License](https://img.shields.io/badge/License-MIT-yellowgreen)](https://choosealicense.com/licenses/mit/)  \n`ebatis`是一个声明式`Elasticsearch ORM`框架。只需要定义接口，便可轻松访问`Elasticsearch`。`ebatis`优雅地帮你隔离业务对`Elasticserach`底层驱动接口的直接调用，你不再需要自己手动去构建繁琐`DSL`\n语句。同时，当升级`Elastisearch`版本的时候，业务可以完全不用关心底层接口的变动，平滑升级。  \n目前，支持`Elastisearch` `6.5.1`与`7.5.1`版本。\n\n# ebatis现状\n\n`ebatis`已经在满帮业务系统上稳定运行近一年，承载着每日近十亿次搜索服务。\n\n# QUICK START\n`POM`依赖（目前也支持`6.5.1.2.RELEASE`）\n```xml\n\u003cdependency\u003e\n     \u003cgroupId\u003eio.manbang\u003c/groupId\u003e\n     \u003cartifactId\u003eebatis-core\u003c/artifactId\u003e\n     \u003cversion\u003e7.5.1.4.RELEASE\u003c/version\u003e\n\u003c/dependency\u003e\n```\n创建集群连接如下:\n```java\n@AutoService(ClusterRouterProvider.class)\npublic class SampleClusterRouterProvider implements ClusterRouterProvider {\n    public static final String SAMPLE_CLUSTER_NAME = \"sampleCluster\";\n \n    @Override\n    public ClusterRouter getClusterRouter(String name) {\n        if (SAMPLE_CLUSTER_NAME.equalsIgnoreCase(name)) {\n            Cluster cluster = Cluster.simple(\"127.0.0.1\", 9200, Credentials.basic(\"admin\", \"123456\"));\n            return ClusterRouter.single(cluster);\n        } else {\n            return null;\n        }\n    }\n}\n```\n定义`POJO`对象如下:\n```java\n@Data\npublic class RecentOrder {\n    private Long cargoId;\n    private String driverUserName;\n    private String loadAddress;\n    private Boolean searchable;\n    private Integer companyId;\n}\n\n@Data\npublic class RecentOrderCondition {\n    private Boolean searchable;\n\n    private String driverUserName;\n}\n```\n定义`Mapper`接口\n```java\n@Mapper(indices = \"recent_order_index\")\npublic interface RecentOrderRepository {\n    @Search\n    List\u003cRecentOrder\u003e search(RecentOrderCondition condition);\n}\n```\n测试接口如下:\n```java\n@Slf4j\npublic class OrderRepositoryTest {\n \n    @Test\n    public void search() {\n        // 组装查询条件\n        RecentOrderCondition condition = new RecentOrderCondition();\n        condition.setSearchable(Boolean.TRUE);\n        condition.setDriverUserName(\"张三\");\n \n        // 映射接口\n        RecentOrderRepository repository = MapperProxyFactory.getMapperProxy(RecentOrderRepository.class, SampleClusterRouterProvider.SAMPLE_CLUSTER_NAME);\n \n        // 搜索货源\n        List\u003cRecentOrder\u003e orders = repository.search(condition);\n \n        // 断言\n        Assert.assertEquals(3, orders.size());\n \n        // 打印输出\n        orders.forEach(order -\u003e log.info(\"{}\", order));\n    }\n}\n```\n搜索得`DSL`语句如下:\n```json\n{\n  \"query\" : {\n    \"bool\" : {\n      \"must\" : [ {\n        \"term\" : {\n          \"searchable\" : {\n            \"value\" : true,\n            \"boost\" : 1.0\n          }\n        }\n      }, {\n        \"term\" : {\n          \"driverUserName\" : {\n            \"value\" : \"张三\",\n            \"boost\" : 1.0\n          }\n        }\n      } ],\n      \"adjust_pure_negative\" : true,\n      \"boost\" : 1.0\n    }\n  },\n  \"_source\" : {\n    \"includes\" : [ \"cargoId\", \"driverUserName\", \"loadAddress\", \"searchable\", \"companyId\" ],\n    \"excludes\" : [ ]\n  }\n}\n```\n`ebatis`版本使用`xx.xx.xx.xx.RELEASE`表示，前三位代表`Elasticsearch`适配集群的驱动版本，后一位代表`ebatis`在此版本上的迭代。例如`7.5.1.3.RELEASE`表示`ebatis`在`Elasticsearch 7.5.1`版本上迭代的第三次版本。\n\n# ebatis入门及相关文章\n\n使用手册:https://github.com/ymm-tech/ebatis/wiki  \n相关文章:https://www.infoq.cn/article/u4Xhw5Q3jfLE1brGhtbR  \n相关文章:https://mp.weixin.qq.com/s/GFRiiQEk-JLpPnCi_WrRqw  \n\n## 交流群\n\n\u003e 钉钉 \n \n\u003cimg src=\"https://github.com/codingPao/ymm-tech/blob/main/ebatisDingDing.JPG?raw=true\" width=\"350px\"\u003e\n\n\n## 支持我们\n\n### 你可以打赏我们 :coffee: 来杯咖啡 :coffee:\n\n\u003cimg src=\"https://github.com/codingPao/ymm-tech/blob/main/coffee.JPG?raw=true\" width=\"360px\"\u003e\n\n### 也可以点个 Star\n开源项目需要的是持续地坚持，而我们坚持的动力当然也来自于你们的支持，希望你 :point_right: `来都来了，加个关注再走吧` :point_left:","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymm-tech%2Febatis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fymm-tech%2Febatis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymm-tech%2Febatis/lists"}