本文整理汇总了Java中org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.setParser方法的典型用法代码示例。如果您正苦于以下问题:Java CommonsHttpSolrServer.setParser方法的具体用法?Java CommonsHttpSolrServer.setParser怎么用?Java CommonsHttpSolrServer.setParser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
的用法示例。
在下文中一共展示了CommonsHttpSolrServer.setParser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer; //导入方法依赖的package包/类
public void init()
{
ParameterCheck.mandatory("solrHost", solrHost);
ParameterCheck.mandatory("solrPort", solrPort);
ParameterCheck.mandatory("solrUser", solrUser);
ParameterCheck.mandatory("solrPassword", solrPassword);
ParameterCheck.mandatory("solrPingCronExpression", solrPingCronExpression);
ParameterCheck.mandatory("solrConnectTimeout", solrConnectTimeout);
try
{
StringBuilder sb = new StringBuilder();
sb.append(httpClientFactory.isSSL() ? "https://" : "http://");
sb.append(solrHost);
sb.append(":");
sb.append(httpClientFactory.isSSL() ? solrSSLPort: solrPort);
sb.append(baseUrl);
this.solrUrl = sb.toString();
HttpClient httpClient = httpClientFactory.getHttpClient();
server = new CommonsHttpSolrServer(solrUrl, httpClient);
server.setParser(new XMLResponseParser());
// TODO remove credentials because we're using SSL?
Credentials defaultcreds = new UsernamePasswordCredentials(solrUser, solrPassword);
server.getHttpClient().getState().setCredentials(new AuthScope(solrHost, solrPort, AuthScope.ANY_REALM),
defaultcreds);
server.setConnectionTimeout(solrConnectTimeout);
server.setSoTimeout(20000);
this.solrTracker = new SolrTracker(scheduler);
}
catch(MalformedURLException e)
{
throw new AlfrescoRuntimeException("Cannot initialise Solr admin http client", e);
}
}
示例2: getPosts
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer; //导入方法依赖的package包/类
public List<ExtendedPost> getPosts(String queryText, String userId, int count) {
List<ExtendedPost> list = new LinkedList<ExtendedPost>();
CommonsHttpSolrServer server = getSolrServer();
server.setParser(new XMLResponseParser());
SolrQuery query = new SolrQuery();
if (queryText.isEmpty()) {
queryText = "*:*";
} else {
queryText = "(text:" + queryText + " || " + "from:" + queryText + " || " + "comments:" + queryText + ")";
}
queryText += " && owner_id:" + userId;
System.out.println(queryText);
query.setQuery(queryText);
query.addSortField("updatedTime", SolrQuery.ORDER.desc);
query.setRows(2000);
try {
QueryResponse rsp = server.query(query);
SolrDocumentList docs = rsp.getResults();
for (SolrDocument d : docs) {
ExtendedPost p = convertToPost(d);
if (p != null) {
list.add(p);
}
}
} catch (SolrServerException ex) {
Logger.getLogger(DataSearcher.class.getName()).log(Level.SEVERE, null, ex);
}
return list;
}