Search in sources :

Example 1 with LuceneIndexManager

use of org.hibernate.search.backend.lucene.index.LuceneIndexManager in project hibernate-search by hibernate.

the class LuceneGetAnalyzerIT method fromIndexManager.

@Test
public void fromIndexManager() {
    // tag::fromIndexManager[]
    // <1>
    SearchMapping mapping = Search.mapping(entityManagerFactory);
    // <2>
    IndexManager indexManager = mapping.indexManager("Book");
    // <3>
    LuceneIndexManager luceneIndexManager = indexManager.unwrap(LuceneIndexManager.class);
    // <4>
    Analyzer indexingAnalyzer = luceneIndexManager.indexingAnalyzer();
    // <5>
    Analyzer searchAnalyzer = luceneIndexManager.searchAnalyzer();
    // end::fromIndexManager[]
    assertThat(indexingAnalyzer).isNotNull();
    assertThat(searchAnalyzer).isNotNull().isNotSameAs(indexingAnalyzer);
}
Also used : LuceneIndexManager(org.hibernate.search.backend.lucene.index.LuceneIndexManager) IndexManager(org.hibernate.search.engine.backend.index.IndexManager) SearchMapping(org.hibernate.search.mapper.orm.mapping.SearchMapping) LuceneIndexManager(org.hibernate.search.backend.lucene.index.LuceneIndexManager) Analyzer(org.apache.lucene.analysis.Analyzer) Test(org.junit.Test)

Example 2 with LuceneIndexManager

use of org.hibernate.search.backend.lucene.index.LuceneIndexManager in project hibernate-search by hibernate.

the class LuceneGetIndexSizeIT method computeIndexSize.

@Test
public void computeIndexSize() {
    // tag::computeIndexSize[]
    // <1>
    SearchMapping mapping = Search.mapping(entityManagerFactory);
    // <2>
    IndexManager indexManager = mapping.indexManager("Book");
    // <3>
    LuceneIndexManager luceneIndexManager = indexManager.unwrap(LuceneIndexManager.class);
    // <4>
    long size = luceneIndexManager.computeSizeInBytes();
    // <5>
    luceneIndexManager.computeSizeInBytesAsync().thenAccept(sizeInBytes -> {
    // ...
    });
    // end::computeIndexSize[]
    assertThat(size).isGreaterThanOrEqualTo(0L);
}
Also used : LuceneIndexManager(org.hibernate.search.backend.lucene.index.LuceneIndexManager) IndexManager(org.hibernate.search.engine.backend.index.IndexManager) SearchMapping(org.hibernate.search.mapper.orm.mapping.SearchMapping) LuceneIndexManager(org.hibernate.search.backend.lucene.index.LuceneIndexManager) Test(org.junit.Test)

Aggregations

LuceneIndexManager (org.hibernate.search.backend.lucene.index.LuceneIndexManager)2 IndexManager (org.hibernate.search.engine.backend.index.IndexManager)2 SearchMapping (org.hibernate.search.mapper.orm.mapping.SearchMapping)2 Test (org.junit.Test)2 Analyzer (org.apache.lucene.analysis.Analyzer)1