本文整理汇总了Java中org.springframework.data.solr.core.SolrTemplate类的典型用法代码示例。如果您正苦于以下问题:Java SolrTemplate类的具体用法?Java SolrTemplate怎么用?Java SolrTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SolrTemplate类属于org.springframework.data.solr.core包,在下文中一共展示了SolrTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDefaultDocumentDecorator
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
/**
* Insure that a non-null document decorator is provided by the abstract impl\
*/
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testDefaultDocumentDecorator() {
Function documentMapper = mock(Function.class);
SolrCrudRepository repository = mock(SolrCrudRepository.class);
SolrTemplate template = mock(SolrTemplate.class);
AbstractEventTupleIndexer underTest = new AbstractEventTupleIndexer(documentMapper, repository, template) {
@Override
public void preIndex(EventDiscoTuple tuple) {
}
@Override
public void postIndex(Object solrDocument) {
}
};
assertNotNull(underTest.documentDecorator);
}
示例2: getTargetRepository
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Object getTargetRepository(RepositoryMetadata metadata) {
SolrOperations operations = this.solrOperations;
if (factory != null) {
SolrTemplate template = new SolrTemplate(factory);
template.setSolrCore(SolrServerUtils.resolveSolrCoreName(metadata.getDomainType()));
addSchemaCreationFeaturesIfEnabled(template);
template.afterPropertiesSet();
operations = template;
}
SimpleSolrRepository repository = new SimpleSolrRepository(getEntityInformation(metadata.getDomainType()),
operations);
repository.setEntityClass(metadata.getDomainType());
this.templateHolder.add(metadata.getDomainType(), operations);
return repository;
}
示例3: registerUriConverter
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
private static void registerUriConverter(SolrTemplate solrTemplate) {
DefaultQueryParser queryParser = new DefaultQueryParser();
queryParser.registerConverter(new Converter<URI, String>() {
@Nullable
@Override
public String convert(URI uri) {
if (uri == null) {
return null;
}
String converted = uri.toString().replaceAll(":", "\\\\:");
return converted;
}
});
solrTemplate.registerQueryParser(Query.class, queryParser);
}
示例4: DiscosIndexer
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param documentMapper {@inheritDoc}
* @param repository {@inheritDoc}
* @param template {@inheritDoc}
*/
public DiscosIndexer(Function<EventDiscoTuple, DiscoSolrDocument> documentMapper,
SolrCrudRepository<DiscoSolrDocument, Long> repository, SolrTemplate template) {
super(documentMapper, repository, template);
// There *is* a Spring Bean definition for DiscoSolrOperations that *ought* to be injected by this constructor.
// However, DiscoSolrOperations test coverage is nill. Testing of DiscoSolrOperations is indirectly
// accomplished by the DiscosIndexerTest, whereby expectations on the SolrTemplate are verified.
// If DiscoSolrOperations is injected into this constructor, then the DiscoIndexerTest would need to be
// re-written with expectations against DiscoSolrOperations, not the SolrTemplate. And DiscoSolrOperations
// would need its own test. All good things, but due to lack of time, leaving this as a TODO.
this.discoOperations = new DiscosSolrOperations(template, CORE_NAME);
}
示例5: SolrRepositoryFactory
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
public SolrRepositoryFactory(SolrOperations solrOperations) {
Assert.notNull(solrOperations);
if (solrOperations instanceof SolrTemplate) {
addSchemaCreationFeaturesIfEnabled((SolrTemplate) solrOperations);
}
this.solrOperations = solrOperations;
this.entityInformationCreator = new SolrEntityInformationCreatorImpl(solrOperations.getConverter()
.getMappingContext());
}
示例6: createTemplate
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
private SolrTemplate createTemplate(SolrServer solrServer) {
SolrTemplate template = new SolrTemplate(solrServer);
addSchemaCreationFeaturesIfEnabled(template);
template.afterPropertiesSet();
return template;
}
示例7: setUp
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
@Before
public void setUp() {
repository = new ExampleSolrBeanRepository();
SolrTemplate template = new SolrTemplate(solrServer, null);
template.afterPropertiesSet();
repository.setSolrOperations(template);
}
示例8: testGetRepositoryOfUnmanageableType
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testGetRepositoryOfUnmanageableType() {
SolrTemplate template = new SolrTemplate(new HttpSolrServer("http://solrserver:8983/solr"), null);
template.afterPropertiesSet();
new SolrRepositoryFactory(template).getRepository(UnmanagedEntityRepository.class);
}
示例9: bootstrapsRepository
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
/**
* @see DATASOLR-72
*/
@SuppressWarnings("rawtypes")
@Test
public void bootstrapsRepository() throws Exception {
Assume.assumeTrue(repository instanceof Advised);
SimpleSolrRepository simpleSolrRepository = (SimpleSolrRepository) ((Advised) repository).getTargetSource()
.getTarget();
SolrTemplate solrTemplate = (SolrTemplate) simpleSolrRepository.getSolrOperations();
solrTemplate.getSchemaCreationFeatures().contains(Feature.CREATE_MISSING_FIELDS);
Assert.assertThat(repository, is(notNullValue()));
}
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:17,代码来源:ITestEnableSolrRepositoriesWithSchemaCreationSupport.java
示例10: createSolrTemplate
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
@Produces
public SolrOperations createSolrTemplate() throws IOException, ParserConfigurationException, SAXException {
EmbeddedSolrServerFactory factory = new EmbeddedSolrServerFactory(ResourceUtils.getURL(
"classpath:org/springframework/data/solr").getPath());
SolrTemplate template = new SolrTemplate(factory);
template.afterPropertiesSet();
return template;
}
示例11: init
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
public ExternalServerWithManagedSchemaRule init() {
SolrTemplate template = new SolrTemplate(new HttpSolrServer(baseUrl));
try {
String schemaName = template.getSchemaName("collection1");
if (!schemaName.equalsIgnoreCase("example-schemaless")) {
errMsg = "Expected to run in schemaless mode";
}
} catch (Exception e) {
errMsg = "Solr Server not running - " + e.getMessage();
}
return this;
}
示例12: setUp
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
@Before
public void setUp() {
this.template = new SolrTemplate(new HttpSolrServer("http://localhost:8983/solr"));
template.setSchemaCreationFeatures(Collections.singletonList(Feature.CREATE_MISSING_FIELDS));
template.afterPropertiesSet();
template.delete(new SimpleQuery("*:*"));
template.commit();
}
示例13: solrTemplate
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
public @Bean SolrTemplate solrTemplate() {
return new SolrTemplate(new HttpSolrClient("http://localhost:8983/solr"), "collection1");
}
示例14: setSolrTemplate
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
@Inject
public void setSolrTemplate(SolrTemplate solrTemplate) {
this.solrTemplate = solrTemplate;
}
示例15: solrTemplate
import org.springframework.data.solr.core.SolrTemplate; //导入依赖的package包/类
@Bean
public SolrTemplate solrTemplate(SolrClient client) throws Exception {
return new SolrTemplate(client);
}