Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
io.manbang:ebatis
ebatis
是一个声明式Elasticsearch ORM
框架。只需要定义接口,便可轻松访问Elasticsearch
。ebatis
优雅地帮你隔离业务对Elasticserach
底层驱动接口的直接调用,你不再需要自己手动去构建繁琐DSL
语句。同时,当升级Elastisearch
版本的时候,业务可以完全不用关心底层接口的变动,平滑升级。
目前,支持Elastisearch
6.5.1
与7.5.1
版本。
ebatis
已经在满帮业务系统上稳定运行近一年,承载着每日近十亿次搜索服务。
POM
依赖(目前也支持6.5.1.2.RELEASE
)
<dependency>
<groupId>io.manbang</groupId>
<artifactId>ebatis-core</artifactId>
<version>7.5.1.4.RELEASE</version>
</dependency>
创建集群连接如下:
@AutoService(ClusterRouterProvider.class)
public class SampleClusterRouterProvider implements ClusterRouterProvider {
public static final String SAMPLE_CLUSTER_NAME = "sampleCluster";
@Override
public ClusterRouter getClusterRouter(String name) {
if (SAMPLE_CLUSTER_NAME.equalsIgnoreCase(name)) {
Cluster cluster = Cluster.simple("127.0.0.1", 9200, Credentials.basic("admin", "123456"));
return ClusterRouter.single(cluster);
} else {
return null;
}
}
}
定义POJO
对象如下:
@Data
public class RecentOrder {
private Long cargoId;
private String driverUserName;
private String loadAddress;
private Boolean searchable;
private Integer companyId;
}
@Data
public class RecentOrderCondition {
private Boolean searchable;
private String driverUserName;
}
定义Mapper
接口
@Mapper(indices = "recent_order_index")
public interface RecentOrderRepository {
@Search
List<RecentOrder> search(RecentOrderCondition condition);
}
测试接口如下:
@Slf4j
public class OrderRepositoryTest {
@Test
public void search() {
// 组装查询条件
RecentOrderCondition condition = new RecentOrderCondition();
condition.setSearchable(Boolean.TRUE);
condition.setDriverUserName("张三");
// 映射接口
RecentOrderRepository repository = MapperProxyFactory.getMapperProxy(RecentOrderRepository.class, SampleClusterRouterProvider.SAMPLE_CLUSTER_NAME);
// 搜索货源
List<RecentOrder> orders = repository.search(condition);
// 断言
Assert.assertEquals(3, orders.size());
// 打印输出
orders.forEach(order -> log.info("{}", order));
}
}
搜索得DSL
语句如下:
{
"query" : {
"bool" : {
"must" : [ {
"term" : {
"searchable" : {
"value" : true,
"boost" : 1.0
}
}
}, {
"term" : {
"driverUserName" : {
"value" : "张三",
"boost" : 1.0
}
}
} ],
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
"_source" : {
"includes" : [ "cargoId", "driverUserName", "loadAddress", "searchable", "companyId" ],
"excludes" : [ ]
}
}
ebatis
版本使用xx.xx.xx.xx.RELEASE
表示,前三位代表Elasticsearch
适配集群的驱动版本,后一位代表ebatis
在此版本上的迭代。例如7.5.1.3.RELEASE
表示ebatis
在Elasticsearch 7.5.1
版本上迭代的第三次版本。
使用手册:https://github.com/ymm-tech/ebatis/wiki
相关文章:https://www.infoq.cn/article/u4Xhw5Q3jfLE1brGhtbR
相关文章:https://mp.weixin.qq.com/s/GFRiiQEk-JLpPnCi_WrRqw
钉钉
开源项目需要的是持续地坚持,而我们坚持的动力当然也来自于你们的支持,希望你 :point_right: 来都来了,加个关注再走吧
:point_left:
FAQs
Elasticsearch ORM Framework
We found that io.manbang:ebatis demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.