You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Joel Bernstein (Jira)" <ji...@apache.org> on 2021/01/26 18:19:00 UTC
[jira] [Commented] (SOLR-14700) CloudSolrClient cannot be used
without setting an explicit streamContext
[ https://issues.apache.org/jira/browse/SOLR-14700?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17272306#comment-17272306 ]
Joel Bernstein commented on SOLR-14700:
---------------------------------------
I just wanted to comment on this.
At this point Streaming Expressions are really designed to be run by passing a String expression to the Stream handler. I should probably just remove the blogs that show the classes being used as they a very out of date.
> CloudSolrClient cannot be used without setting an explicit streamContext
> ------------------------------------------------------------------------
>
> Key: SOLR-14700
> URL: https://issues.apache.org/jira/browse/SOLR-14700
> Project: Solr
> Issue Type: Bug
> Components: clients - java
> Affects Versions: 8.6
> Reporter: Mads Bondo Dydensborg
> Priority: Minor
> Fix For: 8.7, master (9.0)
>
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> A naive approach to using CloudSolrClient, such as on this page: [http://joelsolr.blogspot.com/2015/04/the-streaming-api-solrjio-basics.html] - will not work: opening the stream will throw an IOException with an embedded NullPointerException.
> This took me a while to figure out, and I think it would be good to either update the documentation or "fix" the constructor to set the needed streamContext as appropriate.
> I found this snippet of code in TuppleStream.java, that seems to "almost" work without a streamContext:
> {code:java}
> // line 127 in the sources to TuppleStream.java:
> public static List<String> getShards(String zkHost,
> String collection,
> StreamContext streamContext,
> SolrParams requestParams)
> ...
> // line 135
> if(streamContext != null) {
> shardsMap = (Map<String, List<String>>)streamContext.get("shards");
> }
> ...
> // line 144
> CloudSolrClient cloudSolrClient =
> Optional.ofNullable(streamContext.getSolrClientCache()).orElseGet(SolrClientCache::new).getCloudSolrClient(zkHost);
> {code}
> if streamContext is null in the last statement, a NullPointerException will be thrown and open'ening the stream will fail.
> This took me way too long time to figure out.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org