Example usage for org.apache.solr.handler.extraction ExtractingParams EXTRACT_FORMAT

List of usage examples for org.apache.solr.handler.extraction ExtractingParams EXTRACT_FORMAT

Introduction

In this page you can find the example usage for org.apache.solr.handler.extraction ExtractingParams EXTRACT_FORMAT.

Prototype

String EXTRACT_FORMAT

To view the source code for org.apache.solr.handler.extraction ExtractingParams EXTRACT_FORMAT.

Click Source Link

Document

Content output format if extractOnly is true.

Usage

From source file:org.dspace.discovery.SolrServiceImpl.java

License:BSD License

/**
 * Write the document to the index under the appropriate handle.
 *
 * @param doc the solr document to be written to the server
 * @param streams/* ww  w. j a  v a  2s. c o m*/
 * @throws IOException IO exception
 */
protected void writeDocument(SolrInputDocument doc, List<BitstreamContentStream> streams) throws IOException {

    try {
        if (getSolr() != null) {
            if (CollectionUtils.isNotEmpty(streams)) {
                ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract");

                for (BitstreamContentStream bce : streams) {
                    req.addContentStream(bce);
                }

                ModifiableSolrParams params = new ModifiableSolrParams();

                //req.setParam(ExtractingParams.EXTRACT_ONLY, "true");
                for (String name : doc.getFieldNames()) {
                    for (Object val : doc.getFieldValues(name)) {
                        params.add(ExtractingParams.LITERALS_PREFIX + name, val.toString());
                    }
                }

                req.setParams(params);
                req.setParam(ExtractingParams.UNKNOWN_FIELD_PREFIX, "attr_");
                req.setParam(ExtractingParams.MAP_PREFIX + "content", "fulltext");
                req.setParam(ExtractingParams.EXTRACT_FORMAT, "text");
                req.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
                req.process(getSolr());
            } else {
                getSolr().add(doc);
            }
        }
    } catch (SolrServerException e) {
        log.error(e.getMessage(), e);
    }
}