Re: Re-read from CloudSolrStream

2019-02-20 Thread Joel Bernstein
It sounds like you just need to catch the exception?


Joel Bernstein
http://joelsolr.blogspot.com/


On Mon, Feb 18, 2019 at 3:14 AM SOLR4189  wrote:

> Hi all,
>
> Let's say I have a next code:
>
> http://joelsolr.blogspot.com/2015/04/the-streaming-api-solrjio-basics.html
> <
> http://joelsolr.blogspot.com/2015/04/the-streaming-api-solrjio-basics.html>
>
>
> public class StreamingClient {
>
>public static void main(String args[]) throws IOException {
>   String zkHost = args[0];
>   String collection = args[1];
>
>   Map props = new HashMap();
>   props.put("q", "*:*");
>   props.put("qt", "/export");
>   props.put("sort", "fieldA asc");
>   props.put("fl", "fieldA,fieldB,fieldC");
>
>   CloudSolrStream cstream = new CloudSolrStream(zkHost,
> collection,
> props);
>   try {
>
> cstream.open();
> while(true) {
>
>   Tuple tuple = cstream.read();
>   if(tuple.EOF) {
>  break;
>   }
>
>   String fieldA = tuple.getString("fieldA");
>   String fieldB = tuple.getString("fieldB");
>   String fieldC = tuple.getString("fieldC");
>   System.out.println(fieldA + ", " + fieldB + ", " + fieldC);
> }
>
>   } finally {
>cstream.close();
>   }
>}
> }
>
> What can I do if I get exception in the line *Tuple tuple =
> cstream.read();*? How can I re-read the same tuple, i.e. to continue from
> exception moment ?
>
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
>


Re-read from CloudSolrStream

2019-02-18 Thread SOLR4189
Hi all,

Let's say I have a next code:

http://joelsolr.blogspot.com/2015/04/the-streaming-api-solrjio-basics.html
  

public class StreamingClient {

   public static void main(String args[]) throws IOException {
  String zkHost = args[0];
  String collection = args[1];

  Map props = new HashMap();
  props.put("q", "*:*");
  props.put("qt", "/export");
  props.put("sort", "fieldA asc");
  props.put("fl", "fieldA,fieldB,fieldC");
  
  CloudSolrStream cstream = new CloudSolrStream(zkHost, 
collection, 
props);
  try {
   
cstream.open();
while(true) {
  
  Tuple tuple = cstream.read();
  if(tuple.EOF) {
 break;
  }

  String fieldA = tuple.getString("fieldA");
  String fieldB = tuple.getString("fieldB");
  String fieldC = tuple.getString("fieldC");
  System.out.println(fieldA + ", " + fieldB + ", " + fieldC);
}
  
  } finally {
   cstream.close();
  }
   }
}

What can I do if I get exception in the line *Tuple tuple =
cstream.read();*? How can I re-read the same tuple, i.e. to continue from
exception moment ? 




--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html