What error are you getting?  Does 
http://www.lucidimagination.com/blog/2009/09/14/posting-rich-documents-to-apache-solr-using-solrj-and-solr-cell-apache-tika/
 work for you?

On Apr 28, 2010, at 6:44 AM, Jeroen van Schagen wrote:

> Dear solr-user,
> 
> Using a quartz scheduler, I want to index all documents inside a specific
> folder with Solr(J). To perform the actual indexing I selected the
> org.apache.solr.handler.extraction.ExtractingRequestHandler. The request
> handler functions perfectly when the request is send by curl: curl "
> http://localhost:8080/solr/update/extract?literal.id=doc2&commit=true";  -F
> "tutori...@example.docx"
> 
> But, for some reason, the file is not indexed when using SolrJ. My indexing
> method looks as follow:
> private static final String EXTRACT_REQUEST_MAPPING = "/update/extract";
> private File baseFolder;
> private boolean recursive = false;
> private CommonsHttpSolrServer server;
> public void index(File folder) {
>        if (!folder.isDirectory()) {
>            throw new IllegalArgumentException(folder.getAbsolutePath() + "
> is not a directory.");
>        }
>        logger.info("Indexing documents inside folder [{}]",
> folder.getAbsolutePath());
>        for (File file : folder.listFiles()) {
>            if (file.isFile()) {
>                ContentStreamUpdateRequest up = new
> ContentStreamUpdateRequest(EXTRACT_REQUEST_MAPPING);
>                try {
>                    up.addFile(file);
>                    up.setParam("literal.id", file.getName());
>                    up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true,
> true);
>                    server.request(up);
>                } catch (SolrServerException e) {
>                    logger.error("Could not connect to server.", e);
>                } catch (IOException e) {
>                    logger.error("Could not upload file to server.", e);
>                }
>            } else if (recursive && file.isDirectory()) {
>                index(file); // Index sub-directory as well
>            }
>        }
>    }
> 
> is there something im doing wrong here?

--------------------------
Grant Ingersoll
http://www.lucidimagination.com/

Search the Lucene ecosystem using Solr/Lucene: 
http://www.lucidimagination.com/search

Reply via email to