import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.core.CoreContainer;
/**
* @author 百岁(baisui@taobao.com)
* @date 2013-8-4
*/
public class EmbeddedSolrServerTest {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// Note that the following property could be set through JVM level
// arguments too
System.setProperty("solr.solr.home",
"D:\\tmp\\search4realjhsItem\\search4realjhsItem-0");
CoreContainer.Initializer initializer = new CoreContainer.Initializer();
CoreContainer coreContainer = initializer.initialize();
EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer, "");
SolrQuery query = new SolrQuery();
query.setQuery("tg_type:1");
//query.setFields("ju_id");
QueryResponse result = server.query(query);
System.out.println("result.getResults().getNumFound():"
+ result.getResults().getNumFound());
for (JhsItemPojo item : result.getBeans(JhsItemPojo.class)) {
System.out.print(item.getActivityPrice() + ",");
System.out.println(item.getJuId());
}
}
}