There are no unit tests for stream.file or stream.url. Tests in
org.apache.solr.handler.TestCSVLoader.filename:loadLocal() intercept
them and do its own thing, feeding a local file instead of the
stream.file parameter. I see no proof that stream.file/stream.url
should work in SolrJ or in EmbeddedSolr (which uses the SolrJ API).
This comment is in all known source trees:

    // TODO: stop using locally defined streams once stream.file and
    // stream.body work everywhere

Sorry, you're stuck with the command line. Apologies for giving you
bad advice. I have filed a JIRA about the lack of unit tests:

https://issues.apache.org/jira/browse/SOLR-2060

Please add your source code if you are confident it should work, but does not.

Lance

On Thu, Aug 19, 2010 at 7:45 AM, Tod <listac...@gmail.com> wrote:
> On 8/19/2010 1:45 AM, Lance Norskog wrote:
>>
>> 'stream.url' is just a simple parameter. You should be able to just
>> add it directly.
>
>
> I agree (code excluding imports):
>
> public class CommonTest {
>
>  public static void main(String[] args) {
> System.out.println("main...");
>    try {
>      String fileName = String fileName =
> "http://remoteserver/test/test.pdf";;
>      String solrId = "1234";
>      indexFilesSolrCell(fileName, solrId);
>
>    } catch (Exception ex) {
>      ex.printStackTrace();
>    }
>  }
>
>  /**
>   * Method to index all types of files into Solr.
>   * @param fileName
>   * @param solrId
>   * @throws IOException
>   * @throws SolrServerException
>   */
>  public static void indexFilesSolrCell(String fileName, String solrId)
>    throws IOException, SolrServerException {
>
> System.out.println("indexFilesSolrCell...");
>
>    String urlString = "http://localhost:9080/solr";;
>
> System.out.println("getting connection...");
>    SolrServer solr = new CommonsHttpSolrServer(urlString);
>
> System.out.println("getting updaterequest handle...");
>    ContentStreamUpdateRequest req = new
> ContentStreamUpdateRequest("/update/extract");
>
> System.out.println("setting params...");
>    req.setParam("stream.url", fileName);
>    req.setParam("literal.content_id", solrId);
>
> System.out.println("making request...");
>    solr.request(req);
>
> System.out.println("committing...");
>    solr.commit();
>
> System.out.println("done...");
>  }
> }
>
>
> At "making request" I get:
>
> java.lang.NullPointerException
>        at
> org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:381)
>        at
> org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:243)
>        at CommonTest.indexFilesSolrCell(CommonTest.java:59)
>        at CommonTest.main(CommonTest.java:26)
>
> ... which is pointing to the solr.request(req) line.
>
>
>
> Thanks - Tod
>



-- 
Lance Norskog
goks...@gmail.com

Reply via email to