Hello Vadim, you're right. I will try with the solr mailing list.
Thanx. Francesco -----Original Message----- From: Vadim Roizman [mailto:[email protected]] Sent: Dienstag, 11. März 2014 10:36 To: [email protected] Subject: Re: Many PDFs indexed but only one returned in te Solr-UI Since your problem is in solr (probably SolrInputDocument) usage, you'll get better help at [email protected] Regards, Vadim Roizman On Tue, Mar 11, 2014 at 11:18 AM, Croci Francesco Luigi (ID SWS) <[email protected]> wrote: > I followed the example here > (http://searchhub.org/2012/02/14/indexing-with-solrj/) for indexing > all the pdfs in a directory. The process seems to work well, but at > the end, when I go in the Solr-UI and click on "Execute query"(with > q=*:*), I get only one entry. > > Do I miss something in my code? > > ... > > String[] files = documentDir.list(); > > > > if (files != null) > > { > > for (String document : files) > > { > > ContentHandler textHandler = new BodyContentHandler(); > > Metadata metadata = new Metadata(); > > ParseContext context = new ParseContext(); > > AutoDetectParser autoDetectParser = new AutoDetectParser(); > > > > InputStream inputStream = null; > > > > try > > { > > inputStream = new FileInputStream(new File(documentDir, > document)); > > > > autoDetectParser.parse(inputStream, textHandler, metadata, > context); > > > > SolrInputDocument doc = new SolrInputDocument(); > > doc.addField("id", document); > > > > String content = textHandler.toString(); > > > > if (content != null) > > { > > doc.addField("fullText", content); > > } > > > > UpdateResponse resp = server.add(doc, 1); > > > > server.commit(true, true, true); > > > > if (resp.getStatus() != 0) > > { > > throw new IDSystemException(LOG, "Document could not be indexed. > Status returned: " + resp.getStatus()); > > } > > } > > catch (FileNotFoundException fnfe) > > { > > throw new IDSystemException(LOG, fnfe.getMessage(), fnfe); > > } > > catch (IOException ioe) > > { > > throw new IDSystemException(LOG, ioe.getMessage(), ioe); > > } > > catch (SAXException se) > > { > > throw new IDSystemException(LOG, se.getMessage(), se); > > } > > catch (TikaException te) > > { > > throw new IDSystemException(LOG, te.getMessage(), te); > > } > > catch (SolrServerException sse) > > { > > throw new IDSystemException(LOG, sse.getMessage(), sse); > > } > > finally > > { > > if (inputStream != null) > > { > > try > > { > > inputStream.close(); > > } > > catch (IOException ioe) > > { > > throw new IDSystemException(LOG, ioe.getMessage(), ioe); > > } > > } > > } > > ... > > > > Thank you for any hint. > > > > Francesco -- Regards, Vadim Roizman
