如何debug solr源码

话不多说,按照步骤来,基于 solr 4.5  http://lucene.apache.org/solr/4_5_0/tutorial.html

下载,解压,启动,

启动时候加参数

 java -jar -Dcom.sun.management.jmxremote.port=1090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5889 start.jar

以solr源码目录,新建eclipse工程

远程debug,加断点SolrRequestParsers L169行

   基于SolrJ文件发送查询请求,Test.java 


import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocumentList;

/**
 * 
 */

/**
 * @author 千里
 * 
 */
public class Test {

	/**
	 * @param args
	 * @throws SolrServerException
	 */
	public static void main(String[] args) throws SolrServerException {
		String url = "http://localhost:8983/solr";
		SolrServer server = new HttpSolrServer(url);
		SolrQuery query = new SolrQuery();
		query.setQuery("name:video");
//		query.addSortField("price", SolrQuery.ORDER.asc);
		
		query.addSort("price", SolrQuery.ORDER.asc);
		
		System.out.println(query.toString());
		
		QueryResponse rsp = server.query(query);

		SolrDocumentList docs = rsp.getResults();

		System.out.println(docs.getNumFound());

		System.out.println(docs.size());

		System.out.println(docs.get(0).toString());
		System.out.println(docs.get(1).toString());

		// List<Item> beans = rsp.getBeans(Item.class);
	}

}



就会进入debug模式



你可能感兴趣的:(Lucene,Solr,debu)