Example usage for org.apache.solr.client.solrj.io Tuple getString

List of usage examples for org.apache.solr.client.solrj.io Tuple getString

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.io Tuple getString.

Prototype

public String getString(Object key) 

Source Link

Usage

From source file:com.lucidworks.fusion.support.tests.SolrjStreamingTest.java

public static void main(String[] args) {
    /*/*from  w ww  .  java2 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.stream.SolrTupleStreamingService.java

License:Apache License

@Override
public boolean hasNext() {
    Tuple tuple = readNextTuple();
    if (tuple.getString("EOF").equals("true")) {
        return false;
    } else {//  w  w  w  .ja  v  a 2 s. c  om
        nextTuple = tuple;
        return true;
    }
}