SOLR-1128: added metadata output to extract only option

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@768281 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Grant Ingersoll 2009-04-24 12:42:22 +00:00
parent 31b15cbb23
commit a7a8b3459d
3 changed files with 16 additions and 2 deletions

View File

@ -27,3 +27,5 @@ $Id:$
2. SOLR-284: Removed "silent success" key generation (gsingers)
3. SOLR-1075: Upgrade to Tika 0.3. See http://www.apache.org/dist/lucene/tika/CHANGES-0.3.txt (gsingers)
4. SOLR-1128: Added metadata output to "extract only" option. (gsingers)

View File

@ -21,6 +21,7 @@ import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryResponse;
import org.apache.solr.schema.IndexSchema;
@ -178,7 +179,13 @@ public class ExtractingDocumentLoader extends ContentStreamLoader {
}
rsp.add(stream.getName(), writer.toString());
writer.close();
String[] names = metadata.names();
NamedList metadataNL = new NamedList();
for (int i = 0; i < names.length; i++) {
String[] vals = metadata.getValues(names[i]);
metadataNL.add(names[i], vals);
}
rsp.add(stream.getName() + "_metadata", metadataNL);
}
} catch (Exception e) {
//TODO: handle here with an option to not fail and just log the exception

View File

@ -177,6 +177,11 @@ public class ExtractingRequestHandlerTest extends AbstractSolrTestCase {
assertTrue("extraction is null and it shouldn't be", extraction != null);
assertTrue(extraction + " does not contain " + "solr-word", extraction.indexOf("solr-word") != -1);
NamedList nl = (NamedList) list.get("solr-word.pdf_metadata");
assertTrue("nl is null and it shouldn't be", nl != null);
Object title = nl.get("title");
assertTrue("title is null and it shouldn't be", title != null);
}
public void testXPath() throws Exception {