0
我在我的應用程序中實現了Hibernate Search,即基於Lucene。每當我索引數據庫時,lucene索引的大小都會增加。但是,查詢的結果每次都返回相同的no結果。爲什麼如果我索引相同的數據,lucene索引的大小會增加?
爲什麼每次索引相同的數據時lucene的大小會增加?
FullTextSession fullTextSession = Search.getFullTextSession(getSession());
org.hibernate.Transaction tx = fullTextSession.beginTransaction();
Criteria criteria = fullTextSession.createCriteria(getPersistentClass())
.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY)
.setCacheMode(CacheMode.IGNORE)
.setFetchSize(pageSize)
.setFlushMode(FlushMode.MANUAL);
int i = 0;
List<ProdAttrAssociationVO> results = null;
do {
criteria = criteria.setFirstResult(i)
.setMaxResults(pageSize);
results = criteria.list();
for (ProdAttrAssociationVO entity : results) {
fullTextSession.delete(entity);
fullTextSession.index(entity);
}
// flush the index changes to disk so we don't hold until a commit
if (i % batchSize == 0) {
fullTextSession.flushToIndexes();
fullTextSession.clear();
}
i += pageSize;
} while (results.size() > 0);
System.out.println("ProdAttrAssociation Indexing Completed");
tx.commit();