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


Java CommonsHttpSolrServer.setParser方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:SOLRAdminClient.java

示例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;
}
 
开发者ID:milenchechev,项目名称:RecommendedStream,代码行数:36,代码来源:DataSearcher.java


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