天道酬勤,学无止境

hibernate-search

Hibernate search: persist causes sometimes OverlappingFileLockException

问题 我有一个使用 JPA (Hibernate 5.0.11.Final) 和 Hibernate Search (5.5.5.Final) 运行的 WebAppilcation,用户尝试在其中保存一个新实体。 因此会有几个电话,如: protected Object saveNewEntity(Object toSave) { if (factory == null) { factory = Persistence .createEntityManagerFactory(DBBase.PERSISTENCE_UNIT); } EntityManager em = initEntityManager(); try { em.setFlushMode(FlushModeType.COMMIT); EntityTransaction transaction = em.getTransaction(); transaction.begin(); em.persist(toSave); transaction.commit(); } catch (Exception e) { throw e; } finally { finalizeEntityManager(em); } return toSave; } protected void finalizeEntityManager

2022-05-16 15:42:11    分类:技术分享    hibernate   jpa   hibernate-search

Does Lucene support searching between multiple index documents?

问题 在数据库中: 我有两张桌子。 每个表中有三列。 Table_A (column_primaryKey_A,column_A1,column_A2) Table_B (column_primaryKey_B,column_B1,column_B2) 下面是我想使用 Lucene 执行的 SQL: SELECT * FROM Table_A,Table_B WHERE column_primaryKey_A = column_primaryKey_B AND column_A1 = XX AND column_B1 = XX 我想创建两个索引文档( Index_Table_A , Index_Table_A ),如何使用 Lucene 或 Hibernate Search 的机制来实现上面的东西? . 任何帮助将不胜感激! 回答1 我不确定你为什么需要索引或者为什么要首先使用 lucene,但我可以告诉你如何使用一个索引来实现它。 (使用两个索引是可能的,但性能显着降低) 使用一个索引,索引任何文档,如下所示: title = column_primaryKey_A column_A1 = val... column_A2 = val2... column_B1 = val3... column_B2 = val4... 搜索时,您想对字段查询使用连词查询,如下所示 query

2022-05-04 06:21:18    分类:技术分享    lucene   hibernate-search

Does Lucene support searching between multiple index documents?

In Database : I have two tables. and there are three columns in each table. Table_A (column_primaryKey_A,column_A1,column_A2) Table_B (column_primaryKey_B,column_B1,column_B2) Below is the SQL that I want to do using Lucene: SELECT * FROM Table_A,Table_B WHERE column_primaryKey_A = column_primaryKey_B AND column_A1 = XX AND column_B1 = XX I want to create two index documents(Index_Table_A, Index_Table_A)and how do I implement above things using the mechanism of Lucene or Hibernate Search?. Any help will be thankful!

2022-04-29 14:23:11    分类:问答    lucene   hibernate-search

How to use spatial annotation?

I am using elastic search with hibernate search.I am having a requirement where I have to build tiles map in kibana.For that I need to have geo_point data with latitude and longitude value.I found in hibernate we have @spatial annotation to do this,but when I am using I am getting below exception. java.lang.NullPointerException at org.hibernate.search.engine.metadata.impl.TypeMetadata$Builder.getAnalyzerReference(TypeMetadata.java:631) I am having two model entity and I am writing it below.I am using hibernate search 5.7.0.Final. @Entity @Table(name = "actors", catalog = "twitter") public

2022-04-28 17:33:14    分类:问答    elasticsearch   hibernate-search   hibernate-spatial

How to replace deprecated MultipleHiLoPerTableGenerator with TableGenerator in Hibernate

问题 我在 Spring Boot 1.4.0.RELEASE 的应用程序中使用休眠。 索引的实体看起来类似于: @Entity(name = "SearchableTariffItem") @Indexed public class SearchableTariffItem { public static final String ZIFFER_ANALYZER_NAME = "ZIFFER_ANALYZER"; @GeneratedValue(strategy = GenerationType.TABLE) @Id private Long id; ... } 当我第一次保存实体时,我现在收到以下警告: 2016-08-26 15:08:32.501 WARN 8476 — [apr-8080-exec-6] org.hibernate.orm.deprecation : HHH90000015: Found use of deprecated [org.hibernate.id.MultipleHiLoPerTableGenerator] table-based id generator; use org.hibernate.id.enhanced.TableGenerator instead. See Hibernate Domain Model Mapping Guide

2022-04-27 05:40:09    分类:技术分享    java   spring   hibernate   spring-boot   hibernate-search

Hibernate search: persist causes sometimes OverlappingFileLockException

I have a WebAppilcation runnig with JPA (Hibernate 5.0.11.Final) and Hibernate Search (5.5.5.Final) in which the user tries to save a new entity. Therefor there will be serveral calls like: protected Object saveNewEntity(Object toSave) { if (factory == null) { factory = Persistence .createEntityManagerFactory(DBBase.PERSISTENCE_UNIT); } EntityManager em = initEntityManager(); try { em.setFlushMode(FlushModeType.COMMIT); EntityTransaction transaction = em.getTransaction(); transaction.begin(); em.persist(toSave); transaction.commit(); } catch (Exception e) { throw e; } finally {

2022-04-26 08:55:48    分类:问答    hibernate   jpa   hibernate-search

Indexing huge table with Hibernate Search

问题 我正在尝试将 Hibernate Search 添加到我的项目中以提高搜索性能,但是我在索引大表时遇到了问题。 我添加了 Hibernate Search 依赖项,并且我有一个简单的 servlet 来触发索引过程: FullTextEntityManager ftem = Search.getFullTextEntityManager(em); try { ftem .createIndexer(MyEntity.class) .batchSizeToLoadObjects(25) .cacheMode(CacheMode.NORMAL) .threadsToLoadObjects(5) .startAndWait(); } catch (InterruptedException e) { e.printStackTrace(); } 在我的persistance.xml 中: <property name="hibernate.show_sql" value="false" /> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> <property name="hibernate.archive.autodetection" value=

2022-04-21 14:25:18    分类:技术分享    hibernate   hibernate-search

Hibernate Search sorting

问题 Hibernate搜索是根据相关性对结果进行排序,这是正常的。 除此之外,如果两个文档具有相同的分数,则它们按主键排序。 例如, book1 : id=1, bookTitle = "hibernate search by example"。 book2 : id=2, bookTitle = "hibernate search in action" 如果我正在查询以查找“休眠搜索”一词,我将有以下顺序:book1 然后 book2 我想颠倒这个顺序:book2 然后 book1。 这意味着反转主键顺序。 有没有可能在不实现自定义 Similarity 的情况下做到这一点? 同时保持相关性顺序。 回答1 org.hibernate.search.FullTextQuery query = s.createFullTextQuery( luceneQuery, MyEntity.class ); org.apache.lucene.search.Sort sort = new Sort( SortField.FIELD_SCORE, new SortField("id", SortField.STRING, true)); query.setSort(sort); List results = query.list();

2022-04-20 22:53:43    分类:技术分享    hibernate   lucene   hibernate-search