You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2010/04/27 11:00:01 UTC

[Solr Wiki] Update of "ExtractingRequestHandler" by MarcGhorayeb

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "ExtractingRequestHandler" page has been changed by MarcGhorayeb.
The comment on this change is: Updated the SolrJ section with multiValued field section..
http://wiki.apache.org/solr/ExtractingRequestHandler?action=diff&rev1=57&rev2=58

--------------------------------------------------

  // TODO: describe the different ways to send the documents to solr (POST body, form encoded, remoteStreaming)
   * curl "http://localhost:8983/solr/update/extract?literal.id=doc5&defaultField=text"  --data-binary @tutorial.html  -H 'Content-type:text/html'  
         <!> NOTE, this literally streams the file as the body of the POST, which does not, then, provide info to Solr about the name of the file.
+ 
+ == SolrJ ==
-  * SolrJ:  Use the ContentStreamUpdateRequest (see SolrExampleTests.java for full example):{{{
+ Use the ContentStreamUpdateRequest (see SolrExampleTests.java for full example):
+ {{{
-     ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update/extract");
+ ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update/extract");
-     up.addFile(new File("mailing_lists.pdf"));
+ up.addFile(new File("mailing_lists.pdf"));
-     up.setParam("literal.id", "mailing_lists.pdf");
+ up.setParam("literal.id", "mailing_lists.pdf");
-     up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
+ up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
-     result = server.request(up);
+ result = server.request(up);
-     assertNotNull("Couldn't upload mailing_lists.pdf", result);
+ assertNotNull("Couldn't upload mailing_lists.pdf", result);
-     rsp = server.query( new SolrQuery( "*:*") );
+ rsp = server.query( new SolrQuery( "*:*") );
-     Assert.assertEquals( 1, rsp.getResults().getNumFound() );
+ Assert.assertEquals( 1, rsp.getResults().getNumFound() );
  }}}
+ 
+ If you want to set a '''multiValued''' field, use the ''ModifiableSolrParams'' class like this:
+ {{{
+ p = new ModifiableSolrParams();
+ for(String value : values) {
+     p.add(ExtractingParams.LITERALS_PREFIX + "field", value);
+ }
+ up.setParams(p);
+ }}}
+ 
+ You could also set all of the other literals and parameters in this class, and then use the ''setParams'' method to apply the changes to your content stream.
  
  = Committer Notes =