本文整理汇总了Java中org.hibernate.search.jpa.FullTextEntityManager.index方法的典型用法代码示例。如果您正苦于以下问题:Java FullTextEntityManager.index方法的具体用法?Java FullTextEntityManager.index怎么用?Java FullTextEntityManager.index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.search.jpa.FullTextEntityManager
的用法示例。
在下文中一共展示了FullTextEntityManager.index方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: index
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
public void index(Class<?> type) {
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
if (type == Article.class) {
for (int i = 0; i < articleDao.count(); i += 20) {
List<Article> articles = articleDao.findList(i, 20, null, null);
for (Article article : articles) {
fullTextEntityManager.index(article);
}
fullTextEntityManager.flushToIndexes();
fullTextEntityManager.clear();
articleDao.clear();
}
} else if (type == Product.class) {
for (int i = 0; i < productDao.count(); i += 20) {
List<Product> products = productDao.findList(i, 20, null, null);
for (Product product : products) {
fullTextEntityManager.index(product);
}
fullTextEntityManager.flushToIndexes();
fullTextEntityManager.clear();
productDao.clear();
}
}
}
示例2: test
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
public void test() {
final String testValue = "test";
assertThat(entityWithFullTextRepository.findCount(findByValue(testValue))).isEqualTo(0);
EntityWithFullText entityWithFullText = new EntityWithFullText();
entityWithFullText.setValue(testValue);
entityWithFullText = entityWithFullTextRepository.save(entityWithFullText);
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.index(entityWithFullText);
fullTextEntityManager.flushToIndexes();
fullTextEntityManager.flush();
assertThat(entityWithFullTextRepository.find(findByValue(testValue))).containsExactly(entityWithFullText);
}
示例3: test
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
public void test() {
final String testValue = "test";
assertThat(entityWithMultipleFullTextRepository.findCount(findByValue(testValue))).isEqualTo(0);
EntityWithMultipleFullText entityWithMultipleFullText = new EntityWithMultipleFullText();
entityWithMultipleFullText.setValue1(testValue);
entityWithMultipleFullText.setValue2("abcdef");
entityWithMultipleFullText = entityWithMultipleFullTextRepository.save(entityWithMultipleFullText);
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.index(entityWithMultipleFullText);
fullTextEntityManager.flushToIndexes();
fullTextEntityManager.flush();
assertThat(entityWithMultipleFullTextRepository.find(findByValue(testValue))).containsExactly(entityWithMultipleFullText);
}
示例4: deep_test
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
public void deep_test() {
final String testValue = "test";
assertThat(entityWithMultipleFullTextRepository.findCount(findByDeepValue(testValue))).isEqualTo(0);
EntityWithMultipleFullText entityWithMultipleFullText = new EntityWithMultipleFullText();
entityWithMultipleFullText.setValue1("abcdef");
EntityWithFullText entityWithFullText = new EntityWithFullText();
entityWithFullText.setValue(testValue);
entityWithMultipleFullText.setEntityWithFullText(entityWithFullText);
entityWithMultipleFullText = entityWithMultipleFullTextRepository.save(entityWithMultipleFullText);
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.index(entityWithMultipleFullText);
fullTextEntityManager.flushToIndexes();
fullTextEntityManager.flush();
assertThat(entityWithMultipleFullTextRepository.find(findByDeepValue(testValue))).containsExactly(entityWithMultipleFullText);
}
示例5: test
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
public void test() {
final Integer testValue = 1995;
assertThat(entityWithFullTextIntegerRepository.findCount(findByValue(testValue))).isEqualTo(0);
EntityWithFullTextInteger entityWithFullTextInteger = new EntityWithFullTextInteger();
entityWithFullTextInteger.setValue(testValue);
entityWithFullTextInteger = entityWithFullTextIntegerRepository.save(entityWithFullTextInteger);
EntityWithFullTextInteger another = new EntityWithFullTextInteger();
another.setValue(1994);
entityWithFullTextIntegerRepository.save(another);
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.index(entityWithFullTextInteger);
fullTextEntityManager.flushToIndexes();
fullTextEntityManager.flush();
assertThat(entityWithFullTextIntegerRepository.find(findByValue(testValue))).containsExactly(entityWithFullTextInteger);
}
示例6: testManualIndexing
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
public void testManualIndexing() throws Exception {
this.shouldFindAllGamesInIndex();
FullTextEntityManager fem = this.searchFactory.getFullTextEntityManager( this.em );
fem.beginSearchTransaction();
Game newGame = new Game( "Legend of Zelda" );
newGame.setId( -10L );
fem.index( newGame );
fem.commitSearchTransaction();
Sleep.sleep(
MAX_SLEEP_TIME, () -> {
FullTextQuery fullTextQuery = fem.createFullTextQuery(
fem.getSearchFactory().buildQueryBuilder().forEntity( Game.class ).get().keyword().onField(
"title"
).matching( "Legend of Zelda" ).createQuery(), Game.class
);
// we can find it in the index even though it is not persisted in the database
boolean val1 = 1 == fullTextQuery.getResultSize();
// but no result should be returned here:
boolean val2 = 0 == fullTextQuery.getResultList().size();
return val1 && val2;
}, 100, ""
);
}
示例7: reindexEntity
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Override
public <K extends Serializable & Comparable<K>, E extends GenericEntity<K, ?>> void reindexEntity(E entity) {
if (entity != null) {
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.index(HibernateHelper.unproxy(entity));
}
}
示例8: test_similarity
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
public void test_similarity() {
assertThat(entityWithFullTextRepository.findCount(findByValueWithSimilarity("tast"))).isEqualTo(0);
EntityWithFullText entityWithFullText = new EntityWithFullText();
entityWithFullText.setValue("test");
entityWithFullText = entityWithFullTextRepository.save(entityWithFullText);
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.index(entityWithFullText);
fullTextEntityManager.flushToIndexes();
fullTextEntityManager.flush();
assertThat(entityWithFullTextRepository.find(findByValueWithSimilarity("tast"))).containsExactly(entityWithFullText);
}
示例9: testAnd
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
public void testAnd() {
final String testValue1 = "abc";
final String testValue2 = "def";
assertThat(entityWithMultipleFullTextRepository.findCount(findByValue(testValue1, testValue2))).isEqualTo(0);
EntityWithMultipleFullText entityWithMultipleFullText = new EntityWithMultipleFullText();
entityWithMultipleFullText.setValue1(testValue1);
entityWithMultipleFullText.setValue2(testValue2);
entityWithMultipleFullText = entityWithMultipleFullTextRepository.save(entityWithMultipleFullText);
EntityWithMultipleFullText entityWithMultipleFullText2 = new EntityWithMultipleFullText();
entityWithMultipleFullText2.setValue1(testValue1);
entityWithMultipleFullText2.setValue2("toto");
entityWithMultipleFullText2 = entityWithMultipleFullTextRepository.save(entityWithMultipleFullText2);
EntityWithMultipleFullText entityWithMultipleFullText3 = new EntityWithMultipleFullText();
entityWithMultipleFullText3.setValue1("toto");
entityWithMultipleFullText3.setValue2(testValue2);
entityWithMultipleFullText3 = entityWithMultipleFullTextRepository.save(entityWithMultipleFullText3);
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.index(entityWithMultipleFullText);
fullTextEntityManager.index(entityWithMultipleFullText2);
fullTextEntityManager.index(entityWithMultipleFullText3);
fullTextEntityManager.flushToIndexes();
fullTextEntityManager.flush();
assertThat(entityWithMultipleFullTextRepository.find(findByValue(testValue1, testValue2))).containsExactly(entityWithMultipleFullText);
}
示例10: testMassIndexer
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
public void testMassIndexer()
throws InterruptedException {
Game tmp = new Game( "should not appear in index" );
tmp.setId( -1L );
FullTextEntityManager fem = this.searchFactory.getFullTextEntityManager( null );
fem.beginSearchTransaction();
fem.index( tmp );
fem.commitSearchTransaction();
//all the minimum stuff, so we can testCustomUpdatedEntity with our little amount of entities
//the beefy tests are done in the jpa module anyways
//we just want to testCustomUpdatedEntity whether we can do the indexing
//in a EJB context :)
this.searchFactory.pauseUpdating( true );
try {
this.searchFactory.getFullTextEntityManager( this.em )
.createIndexer( Game.class )
.batchSizeToLoadIds( 1 )
.batchSizeToLoadObjects( 1 )
.threadsToLoadIds( 1 )
.threadsToLoadObjects( 1 )
//just make sure there is no exception in setting this limit, we can't really testCustomUpdatedEntity this properly as of now
//manual testCustomUpdatedEntity showed this was done correctly
.idProducerTransactionTimeout( 1000 ).startAndWait();
assertEquals(
GAME_TITLES.length, this.searchFactory.getFullTextEntityManager( this.em ).createFullTextQuery(
new MatchAllDocsQuery(),
Game.class
).getResultList().size()
);
}
finally {
this.searchFactory.pauseUpdating( false );
}
}
示例11: testRollback
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
public void testRollback() throws Exception {
this.shouldFindAllGamesInIndex();
FullTextEntityManager fem = this.searchFactory.getFullTextEntityManager( this.em );
fem.beginSearchTransaction();
Game newGame = new Game( "Pong" );
newGame.setId( -10L );
fem.index( newGame );
fem.rollbackSearchTransaction();
Sleep.sleep(
MAX_SLEEP_TIME, () -> {
FullTextQuery fullTextQuery = fem.createFullTextQuery(
fem.getSearchFactory()
.buildQueryBuilder()
.forEntity( Game.class )
.get()
.keyword()
.onField(
"title"
)
.matching( "Pong" )
.createQuery(),
Game.class
);
// we can find it in the index even though it is not persisted in the database
boolean val1 = 0 == fullTextQuery.getResultSize();
// no result should be returned here either
boolean val2 = 0 == fullTextQuery.getResultList().size();
return val1 && val2;
}, 100, ""
);
}
示例12: testRollback
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
public void testRollback() throws Exception {
this.shouldFindAllGamesInIndex();
FullTextEntityManager fem = this.searchFactory.getFullTextEntityManager( this.em );
fem.beginSearchTransaction();
Game newGame = new Game( "Pong" );
fem.index( newGame );
newGame.setId( -10L );
fem.rollbackSearchTransaction();
Sleep.sleep(
MAX_SLEEP_TIME, () -> {
FullTextQuery fullTextQuery = fem.createFullTextQuery(
fem.getSearchFactory()
.buildQueryBuilder()
.forEntity( Game.class )
.get()
.keyword()
.onField(
"title"
)
.matching( "Pong" )
.createQuery(),
Game.class
);
// we can find it in the index even though it is not persisted in the database
boolean val1 = 0 == fullTextQuery.getResultSize();
// no result should be returned here either
boolean val2 = 0 == fullTextQuery.getResultList().size();
return val1 && val2;
}, 100, ""
);
}
开发者ID:Hotware,项目名称:Hibernate-Search-GenericJPA,代码行数:34,代码来源:EclipseLinkGlassFishIntegrationTest.java
示例13: manualIndexing
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Test
@Ignore
public void manualIndexing() {
EntityManager em = emf.createEntityManager();
FullTextEntityManager ftem = Search.getFullTextEntityManager( em );
ftem.getTransaction().begin();
VideoGame game = ftem.find( VideoGame.class, 311 );
ftem.index( game );
ftem.getTransaction().commit();
}
示例14: index
import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Override
public void index(Object o)
{
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.index(o);
}