如何使用 Hibernate

您所在的位置:网站首页 elasticsearch数据存储在哪 如何使用 Hibernate

如何使用 Hibernate

2023-02-03 15:32| 来源: 网络整理| 查看: 265

我正在使用休眠搜索将我的实体映射到 MySQL 和 ElasticSearch。

我希望 elasticsearch 文档的索引方式与实际索引方式之间存在差异。

我有一个名为 的Product实体ProductImage。我希望ProductImage实体在 elasticsearch 索引中被序列化为一个字符串数组。

我有这个:

关系世界(MySQL):

> 产品表 ______________________________ | 金 | 价格 | 其他东西 | ------------------------------ > 产品图片表 _______________ | 金 | 路径 | ---------------

无关系世界(Elasticsearch 索引):

http://elasticsearch.domain.com/products/com.example.Product/_search { "gtin" : "1234" "images" : [ { "path" : "http://image.host.com/product-image-1" }, { "path" : "http://image.host.com/product-image-2" } ] } 但我想要这个: http://elasticsearch.domain.com/products/com.example.Product/_search { "gtin" : "1234" "images" : [ "http://image.host.com/product-image-1", "http://image.host.com/product-image-2" ] }

这是我的实现:

@Entity @Table(name = "products") @Indexed(index = "products") public class Product implements Serializable { @Id String gtin; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumn(name = "gtin", referencedColumnName = "gtin") @IndexedEmbedded Set images = new TreeSet(); }

@Entity @Table(name = "product_images") public class ProductImage implements Serializable { @EmbeddedId @Field @FieldBridge(impl = IdBridge.class) //@ContainedId


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3