List of usage examples for org.apache.solr.client.solrj.io.stream CloudSolrStream children
public List<TupleStream> children()
From source file:com.lucidworks.fusion.support.tests.SolrjStreamingTest.java
public static void main(String[] args) { /*/*from w w w.ja va 2s.co m*/ try{ StreamFactory streamFactory = new StreamFactory().withCollectionZkHost("collection1", zkServer.getZkAddress()) .withStreamFunction("search", CloudSolrStream.class) .withStreamFunction("unique", UniqueStream.class) .withStreamFunction("top", RankStream.class) .withStreamFunction("group", ReducerStream.class) .withStreamFunction("parallel", ParallelStream.class); ParallelStream pstream = (ParallelStream)streamFactory.constructStream("parallel(collection1, group(search(collection1, q=\"*:*\", fl=\"id,a_s,a_i,a_f\", sort=\"a_s asc,a_f asc\", partitionKeys=\"a_s\"), by=\"a_s asc\"), workers=\"2\", zkHost=\""+zkHost+"\", sort=\"a_s asc\")"); }catch(Exception e){ e.printStackTrace(); } */ String zkHost = "localhost:9983";//args[0]; String collection = "fbo_test";//args[1]; CloudSolrStream cstream = null; Map props = new HashMap(); try { props.put("q", "*:*"); props.put("qt", "/export"); props.put("sort", "id asc"); props.put("fl", "id,body"); props.put("rows", "20"); cstream = new CloudSolrStream(zkHost, collection, props); cstream.open(); System.out.println("children: " + cstream.children().size()); while (true) { Tuple tuple = cstream.read(); if (tuple.EOF) { System.out.println("BREAK"); break; } String fieldA = tuple.getString("id"); String fieldB = tuple.getString("body"); String fieldC = " ";//tuple.getString("resourceName"); System.out.println(fieldA + ", " + fieldB + ", " + fieldC); } } catch (Exception e) { e.printStackTrace(); } finally { try { cstream.close(); } catch (Exception e) { } } }