[英]What is the difference between SolrTemplate and SolrClient?
I was documenting my code that i wrote following some tutorials on Spring data for solr apache, and i realised i didn't know the diference between a solrTemplate
and a SolrClient
?我正在记录我在 Spring 数据的 solr apache 的一些教程之后编写的代码,我意识到我不知道
solrTemplate
和SolrClient
之间的区别?
i was documenting the following code:我正在记录以下代码:
@Configuration
@EnableSolrRepositories(basePackages = {"com.anouar.solr.nomenclaturespringdatasolr.repository",
"com.anouar.solr.nomenclaturespringdatasolr.dataImportHandler"},
namedQueriesLocation = "classpath:solr-named-queries.properties")
public class SolrConfig {
@Value("${spring.data.solr.host}")
String solrURL;
/**
* returns the bean that establishes the connection with Solr through port 8983
*
* @return SolrClient
*
* **/
@Bean
public SolrClient solrClient() {
return new HttpSolrClient.Builder(solrURL).build();
}
/**
*
* @param client the bean that is connected to Solr through port 8983
*
* **/
@Bean
public SolrTemplate solrTemplate(SolrClient client) throws Exception {
return new SolrTemplate(client);
}
}
Below is the description from apache documentation for SolrClient
以下是 SolrClient 的
SolrClient
文档中的描述
Abstraction through which all communication with a Solr server may be routed
which means all your solr calls will be route via solrClient so we need to configure solr server address, port(few other also) to solrClient
.这意味着您的所有 solr 调用都将通过 solrClient 路由,因此我们需要将 solr 服务器地址、端口(也很少)配置为
solrClient
。
where as solrTemplate
is for solr operations like query, count, etc.. solrTemplate
will use solrClient
that's why while configuring solrTemplate
, solrClient
is passed.其中
solrTemplate
用于 solr 操作,如查询、计数等。 solrTemplate
将使用solrClient
这就是为什么在配置solrTemplate
时,会传递solrClient
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.