You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by SOLR4189 <Kl...@yandex.ru> on 2019/02/18 08:14:40 UTC
Re-read from CloudSolrStream
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: Re-read from CloudSolrStream
Posted by Joel Bernstein <jo...@gmail.com>.
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 <Kl...@yandex.ru> 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
>