Java 类org.hibernate.search.spi.SearchIntegrator 实例源码

项目:spring-data-snowdrop    文件:TestUtils.java   
public static void deleteEntities(DatasourceMapperTester datasourceMapper, AbstractEntity... entities) {
    println("Starting index removal...");
    SearchIntegrator searchIntegrator = datasourceMapper.getSearchIntegrator();
    Worker worker = searchIntegrator.getWorker();
    TransactionContextTester tc = new TransactionContextTester();
    boolean needsFlush = false;
    int i = 1;
    for (; i <= entities.length; i++) {
        AbstractEntity entity = entities[i - 1];
        Work work = new Work(entity, entity.getId(), WorkType.DELETE, false);
        worker.performWork(work, tc);
        needsFlush = true;
        if (i % 1000 == 0) {
            //commit in batches of 1000:
            tc.end();
            needsFlush = false;
            tc = new TransactionContextTester();
        }
    }
    if (needsFlush) {
        //commit remaining work
        tc.end();
    }
    println(" ... removed an index of " + (i - 1) + " entities.");
}
项目:owsi-core-parent    文件:HibernateSearchDaoImpl.java   
@Override
public Analyzer getAnalyzer(Class<?> entityType) {
    if (jpaPropertiesProvider.isHibernateSearchElasticSearchEnabled()) {
        ExtendedSearchIntegrator searchIntegrator = Search.getFullTextEntityManager(getEntityManager())
                .getSearchFactory().unwrap(ExtendedSearchIntegrator.class);
        ScopedElasticsearchAnalyzer scopedAnalyzer = (ScopedElasticsearchAnalyzer) searchIntegrator.getAnalyzerReference(entityType).getAnalyzer();

        try {
            // these properties are package protected !
            ElasticsearchAnalyzer globalAnalyzer = (ElasticsearchAnalyzer) FieldUtils.getField(ScopedElasticsearchAnalyzer.class, "globalAnalyzer", true).get(scopedAnalyzer);
            @SuppressWarnings("unchecked")
            Map<String, ElasticsearchAnalyzer> analyzers = (Map<String, ElasticsearchAnalyzer>) FieldUtils.getField(ScopedElasticsearchAnalyzer.class, "scopedAnalyzers", true).get(scopedAnalyzer);

            Map<String, Analyzer> luceneAnalyzers = Maps.newHashMap();
            for (Entry<String, ElasticsearchAnalyzer> analyzer : analyzers.entrySet()) {
                luceneAnalyzers.put(analyzer.getKey(), getAnalyzer(analyzer.getValue().getName(null)));
            }
            return new ScopedLuceneAnalyzer(getAnalyzer(globalAnalyzer.getName(null)) /* parameter is not used */, luceneAnalyzers);
        } catch (IllegalAccessException e) {
            throw new RuntimeException("illegal access on scoped analyzer", e);
        }
    } else {
        return Search.getFullTextEntityManager(getEntityManager()).getSearchFactory().unwrap(SearchIntegrator.class).getAnalyzer(entityType);
    }
}
项目:spring-data-snowdrop    文件:TestUtils.java   
public static SearchIntegrator createSearchIntegrator(Class<?>... classes) {
    SearchConfigurationTester configuration = SearchConfigurationTester.noTestDefaults();
    configuration.addClasses(classes);
    SearchIntegratorBuilder builder = new SearchIntegratorBuilder();
    builder.configuration(configuration);
    return builder.buildSearchIntegrator();
}
项目:spring-data-snowdrop    文件:TestUtils.java   
public static void preindexEntities(DatasourceMapperTester datasourceMapper, AbstractEntity... entities) {
    println("Starting index creation...");
    SearchIntegrator searchIntegrator = datasourceMapper.getSearchIntegrator();
    Worker worker = searchIntegrator.getWorker();
    TransactionContextTester tc = new TransactionContextTester();
    boolean needsFlush = false;
    int i = 1;
    for (; i <= entities.length; i++) {
        AbstractEntity entity = entities[i - 1];
        Work work = new Work(entity, entity.getId(), WorkType.ADD, false);
        worker.performWork(work, tc);
        //noinspection unchecked
        datasourceMapper.put(entity);
        needsFlush = true;
        if (i % 1000 == 0) {
            //commit in batches of 1000:
            tc.end();
            needsFlush = false;
            tc = new TransactionContextTester();
        }
    }
    if (needsFlush) {
        //commit remaining work
        tc.end();
    }
    println(" ... created an index of " + (i - 1) + " entities.");
}
项目:spring-data-snowdrop    文件:TestUtils.java   
public static void purgeAll(DatasourceMapperTester datasourceMapper, Class<?> entityClass) {
    println("Purging index - " + entityClass.getSimpleName() + " ...");
    SearchIntegrator searchIntegrator = datasourceMapper.getSearchIntegrator();
    Worker worker = searchIntegrator.getWorker();
    TransactionContextTester tc = new TransactionContextTester();
    IndexedTypeIdentifier indexedTypeIdentifier = PojoIndexedTypeIdentifier.convertFromLegacy(entityClass);
    Work work = new Work(indexedTypeIdentifier, null, WorkType.PURGE_ALL);
    worker.performWork(work, tc);
    tc.end();
    datasourceMapper.clear();
}
项目:owsi-core-parent    文件:HibernateSearchDaoImpl.java   
@Override
public Analyzer getAnalyzer(String analyzerName) {
    if (jpaPropertiesProvider.isHibernateSearchElasticSearchEnabled()) {
        if ("default".equals(analyzerName)) {
            return PassThroughAnalyzer.INSTANCE;
        } else {
            return Search.getFullTextEntityManager(getEntityManager()).getSearchFactory().unwrap(SearchIntegrator.class)
                    .getAnalyzer(CoreLuceneClientAnalyzersDefinitionProvider.ANALYZER_NAME_PREFIX + analyzerName);
        }
    } else {
        return Search.getFullTextEntityManager(getEntityManager()).getSearchFactory().unwrap(SearchIntegrator.class).getAnalyzer(analyzerName);
    }
}
项目:Hibernate-Search-GenericJPA    文件:StandaloneSearchFactoryFactory.java   
public static StandaloneSearchFactory createSearchFactory(
        SearchConfiguration searchConfiguration,
        Collection<Class<?>> classes) {
    SearchIntegratorBuilder builder = new SearchIntegratorBuilder();
    // we have to build an integrator here (but we don't need it afterwards)
    builder.configuration( searchConfiguration ).buildSearchIntegrator();
    classes.forEach( builder::addClass );
    SearchIntegrator impl = builder.buildSearchIntegrator();
    return new StandaloneSearchFactoryImpl( impl.unwrap( ExtendedSearchIntegrator.class ) );
}
项目:spring-data-snowdrop    文件:DatasourceMapperTester.java   
public DatasourceMapperTester(SearchIntegrator searchIntegrator) {
    this.searchIntegrator = searchIntegrator;
}
项目:spring-data-snowdrop    文件:DatasourceMapperTester.java   
public SearchIntegrator getSearchIntegrator() {
    return searchIntegrator;
}
项目:spring-data-snowdrop    文件:TestUtils.java   
public static <T extends AbstractEntity> DatasourceMapperTester<T> createDatasourceMapper(Class<T> entityClass) {
    SearchIntegrator searchIntegrator = createSearchIntegrator(entityClass);
    return new DatasourceMapperTester<T>(searchIntegrator);
}
项目:spring-data-snowdrop    文件:InfinispanEmbeddedDatasourceMapper.java   
protected SearchIntegrator getSearchIntegrator() {
    return searchManager.unwrap(SearchIntegrator.class);
}
项目:spring-data-snowdrop    文件:JpaDatasourceMapper.java   
protected SearchIntegrator getSearchIntegrator() {
    if (searchIntegrator == null) {
        searchIntegrator = ContextHelper.getSearchIntegratorBySF(emf.unwrap(SessionFactoryImplementor.class));
    }
    return searchIntegrator;
}
项目:windup-rulesets    文件:JMSController.java   
@Override
protected SearchIntegrator getSearchIntegrator()
{
    // TODO Auto-generated method stub
    return null;
}
项目:Hibernate-Search-GenericJPA    文件:HSearchQueryImpl.java   
public HSearchQueryImpl(HSQuery hsquery, DtoQueryExecutor queryExec, SearchIntegrator searchIntegrator) {
    this.hsquery = hsquery;
    this.queryExec = queryExec;
    this.searchIntegrator = searchIntegrator;
}
项目:Hibernate-Search-GenericJPA    文件:SearchFactoryTest.java   
@Test
public void testWithoutNewClasses() {
    SearchConfiguration searchConfiguration = new StandaloneSearchConfiguration();
    List<Class<?>> classes = Arrays.asList( TopLevel.class );

    SearchIntegratorBuilder builder = new SearchIntegratorBuilder();
    // we have to build an integrator here (but we don't need it afterwards)
    builder.configuration( searchConfiguration ).buildSearchIntegrator();
    classes.forEach(
            (clazz) -> {
                builder.addClass( clazz );
            }
    );
    SearchIntegrator impl = builder.buildSearchIntegrator();

    TopLevel tl = new TopLevel();
    tl.setId( 123 );
    Embedded eb = new Embedded( 1 );

    List<Embedded2> embedded2 = new ArrayList<>();
    {
        Embedded2 e1 = new Embedded2();
        e1.setEmbedded( eb );
        embedded2.add( e1 );

        Embedded2 e2 = new Embedded2();
        e2.setEmbedded( eb );
        embedded2.add( e1 );
    }
    eb.setEmbedded2( embedded2 );

    tl.setEmbedded( eb );
    Transaction tc = new Transaction();

    impl.getWorker().performWork( new Work( tl, WorkType.ADD ), tc );

    tc.commit();

    assertEquals(
            1, impl.createHSQuery().luceneQuery( new MatchAllDocsQuery() ).targetedEntities(
                    Collections.singletonList(
                            TopLevel.class
                    )
            ).queryResultSize()
    );
}
项目:spring-data-snowdrop    文件:LuceneQueryAdapter.java   
protected abstract SearchIntegrator getSearchIntegrator();