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?

Reply via email to