当前位置: 首页>>代码示例>>Java>>正文


Java FullTextEntityManager.index方法代码示例

本文整理汇总了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();
		}
	}
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:25,代码来源:SearchServiceImpl.java

示例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);
}
 
开发者ID:jpasearch,项目名称:jpasearch,代码行数:18,代码来源:EntityWithFullTextRepositoryIT.java

示例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);
}
 
开发者ID:jpasearch,项目名称:jpasearch,代码行数:19,代码来源:EntityWithMultipleFullTextRepositoryIT.java

示例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);
}
 
开发者ID:jpasearch,项目名称:jpasearch,代码行数:21,代码来源:EntityWithMultipleFullTextRepositoryIT.java

示例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);
}
 
开发者ID:jpasearch,项目名称:jpasearch,代码行数:21,代码来源:EntityWithFullTextIntegerRepositoryIT.java

示例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, ""
	);
}
 
开发者ID:Hotware,项目名称:Hibernate-Search-GenericJPA,代码行数:25,代码来源:OpenJPATomEEIntegrationTest.java

示例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));
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:8,代码来源:HibernateSearchDaoImpl.java

示例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);
}
 
开发者ID:jpasearch,项目名称:jpasearch,代码行数:16,代码来源:EntityWithFullTextRepositoryIT.java

示例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);
}
 
开发者ID:jpasearch,项目名称:jpasearch,代码行数:32,代码来源:EntityWithMultipleFullTextRepositoryIT.java

示例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 );
	}
}
 
开发者ID:Hotware,项目名称:Hibernate-Search-GenericJPA,代码行数:36,代码来源:OpenJPATomEEIntegrationTest.java

示例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, ""
	);
}
 
开发者ID:Hotware,项目名称:Hibernate-Search-GenericJPA,代码行数:34,代码来源:OpenJPATomEEIntegrationTest.java

示例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();
}
 
开发者ID:hibernate,项目名称:hibernate-demos,代码行数:14,代码来源:HibernateSearchWithElasticsearchIT.java

示例14: index

import org.hibernate.search.jpa.FullTextEntityManager; //导入方法依赖的package包/类
@Override
public void index(Object o)
{
    FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
    fullTextEntityManager.index(o);
}
 
开发者ID:michal-ruzicka,项目名称:MathMLCanEval,代码行数:7,代码来源:IndexToolsImpl.java


注:本文中的org.hibernate.search.jpa.FullTextEntityManager.index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。