List of usage examples for org.apache.solr.client.solrj.io.stream CloudSolrStream open
public void open() throws IOException
From source file:com.lucidworks.fusion.support.tests.SolrjStreamingTest.java
public static void main(String[] args) { /*//from ww w .j ava 2 s .c o 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) { } } }
From source file:de.qaware.chronix.storage.solr.ChronixSolrCloudStorage.java
License:Apache License
/** * Fetches a stream of time series only from a single node with CloudSolrStream. * * @param zkHost//w w w.j av a 2 s. c o m * @param collection * @param shardUrl * @param query * @param converter * @return * @throws IOException */ private Stream<MetricTimeSeries> streamWithCloudSolrStream(String zkHost, String collection, String shardUrl, SolrQuery query, TimeSeriesConverter<MetricTimeSeries> converter) throws IOException { Map params = new HashMap(); params.put("q", query.getQuery()); params.put("sort", "id asc"); params.put("shards", extractShardIdFromShardUrl(shardUrl)); params.put("fl", Schema.DATA + ", " + Schema.ID + ", " + Schema.START + ", " + Schema.END + ", metric, host, measurement, process, ag, group"); params.put("qt", "/export"); params.put("distrib", false); CloudSolrStream solrStream = new CloudSolrStream(zkHost, collection, params); solrStream.open(); SolrTupleStreamingService tupStream = new SolrTupleStreamingService(solrStream, converter); return StreamSupport.stream(Spliterators.spliteratorUnknownSize(tupStream, Spliterator.SIZED), false); }