문제

Lucene을 기반으로 응용 프로그램 IE에서 최대 절전 모드 검색을 구현했습니다. 데이터베이스를 색인 할 때마다 Lucene Indexes의 크기가 증가합니다. 그러나 쿼리의 결과는 매번 동일한 결과를 반환하지 않습니다.

매번 동일한 데이터를 색인하면 루센의 크기가 매번 증가하는 이유는 무엇입니까?

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();
도움이 되었습니까?

해결책

최대 절전 모드에 대해서는 아무것도 모르지만 일반적으로 루센에서 삭제 된 문서는 최적화 될 때까지 색인을 유지합니다. 그것은 당신이 지수가 성장하는 이유를 설명 할 수 있습니다.

인덱스에서 최적화 ()를 실행하십시오. 최대 절전 모드에서 어떻게하는지 잘 모르겠습니다 (나는 그것이 어떻게 searchFactory).

도움이 되었기를 바랍니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top