当前位置: 首页>>代码示例>>Java>>正文


Java SolrInputDocument.getFieldValue方法代码示例

本文整理汇总了Java中org.apache.solr.common.SolrInputDocument.getFieldValue方法的典型用法代码示例。如果您正苦于以下问题:Java SolrInputDocument.getFieldValue方法的具体用法?Java SolrInputDocument.getFieldValue怎么用?Java SolrInputDocument.getFieldValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.common.SolrInputDocument的用法示例。


在下文中一共展示了SolrInputDocument.getFieldValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkAndCreateGroupDoc_shouldCreateNewDocumentWithAllValuesIfNoneExists

import org.apache.solr.common.SolrInputDocument; //导入方法依赖的package包/类
/**
 * @see SolrHelper#checkAndCreateGroupDoc(String,String,long)
 * @verifies create new document with all values if none exists
 */
@Test
public void checkAndCreateGroupDoc_shouldCreateNewDocumentWithAllValuesIfNoneExists() throws Exception {
    Map<String, String> moreMetadata = new HashMap<>();
    moreMetadata.put("MD_SHELFMARK", "shelfmark");
    moreMetadata.put("MD_TITLE", "title");
    SolrInputDocument doc = solrHelper.checkAndCreateGroupDoc(SolrConstants.GROUPID_ + "TEST", "id10T", moreMetadata, 123456L);
    Assert.assertNotNull(doc);
    Assert.assertEquals("123456", doc.getFieldValue(SolrConstants.IDDOC));
    Long timestamp = (Long) doc.getFieldValue(SolrConstants.DATECREATED);
    Assert.assertNotNull(timestamp);
    Assert.assertEquals(timestamp, doc.getFieldValue(SolrConstants.DATEUPDATED));
    Assert.assertEquals(DocType.GROUP.name(), doc.getFieldValue(SolrConstants.DOCTYPE));
    Assert.assertEquals("id10T", doc.getFieldValue(SolrConstants.PI));
    Assert.assertEquals(SolrConstants.GROUPID_ + "TEST", doc.getFieldValue(SolrConstants.GROUPTYPE));
    Assert.assertEquals("shelfmark", doc.getFieldValue("MD_SHELFMARK"));
    Assert.assertEquals("title", doc.getFieldValue("MD_TITLE"));
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:22,代码来源:SolrHelperTest.java

示例2: writeDocs

import org.apache.solr.common.SolrInputDocument; //导入方法依赖的package包/类
/**
 * @param aggregateRecords
 * @throws IndexerException
 * @throws FatalIndexerException
 * @see de.intranda.digiverso.presentation.solr.model.ISolrWriteStrategy#writeDocs()
 * @should write all structure docs correctly
 * @should write all page docs correctly
 */
@Override
public void writeDocs(boolean aggregateRecords) throws IndexerException, FatalIndexerException {
    if (rootDoc == null) {
        throw new IndexerException("rootDoc may not be null");
    }

    for (int order : pageOrderMap.keySet()) {
        SolrInputDocument pageDoc = pageOrderMap.get(order);
        checkAndAddAccessCondition(pageDoc);
        docsToAdd.add(pageDoc);
    }

    for (SolrInputDocument doc : docsToAdd) {
        if (doc.getFieldValue("GROUPFIELD") == null) {
            logger.error("Field has no GROUPFIELD: {}", doc.toString());
        }
        rootDoc.addChildDocument(doc);
        if (aggregateRecords) {
            if (doc.containsKey(SolrConstants.DEFAULT)) {
                rootDoc.addField(SolrConstants.SUPERDEFAULT, (doc.getFieldValue(SolrConstants.DEFAULT)));
            }
            //                if (doc.containsKey(SolrConstants.NORMDATATERMS)) {
            //                    rootDoc.addField(SolrConstants.NORMDATATERMS, doc.getFieldValue(SolrConstants.NORMDATATERMS));
            //                }
            if (doc.containsKey(SolrConstants.FULLTEXT)) {
                rootDoc.addField(SolrConstants.SUPERFULLTEXT, (doc.getFieldValue(SolrConstants.FULLTEXT)));
            }
        }
    }

    solrHelper.writeToIndex(rootDoc);
    solrHelper.commit(SolrHelper.optimize);
    logger.debug("{} new doc(s) added.", docsToAdd.size());
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:43,代码来源:HierarchicalLazySolrWriteStrategy.java

示例3: addPageDoc

import org.apache.solr.common.SolrInputDocument; //导入方法依赖的package包/类
@Override
public void addPageDoc(SolrInputDocument doc) {
    int order = (Integer) doc.getFieldValue(SolrConstants.ORDER);
    if (pageOrderMap.get(order) != null) {
        logger.error("Collision for page order {}", order);
    }
    pageOrderMap.put(order, doc);
    String key = (String) doc.getFieldValue(SolrConstants.PHYSID);
    physIdPageMap.put(key, doc);
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:11,代码来源:LazySolrWriteStrategy.java

示例4: addPageDoc

import org.apache.solr.common.SolrInputDocument; //导入方法依赖的package包/类
@Override
public void addPageDoc(SolrInputDocument doc) {
    String iddoc = String.valueOf(doc.getFieldValue(SolrConstants.IDDOC));
    if (doc.getField(SolrConstants.FULLTEXT) != null) {
        String text = (String) doc.getFieldValue(SolrConstants.FULLTEXT);
        try {
            FileUtils.writeStringToFile(new File(tempFolder.toFile(), iddoc + "_" + SolrConstants.FULLTEXT), text, ENCODING_UTF8);
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }
        doc.removeField(SolrConstants.FULLTEXT);
    }
    if (save(doc, iddoc)) {
        int order = (int) doc.getFieldValue(SolrConstants.ORDER);
        if (pageDocOrderIddocMap.get(order) != null) {
            logger.error("Collision for page order {}", order);
        }
        pageDocOrderIddocMap.put(order, iddoc);
        if (pageDocFileNameIddocMap.get(doc.getFieldValue(SolrConstants.FILENAME)) != null) {
            logger.warn("A doc already exists for file: {}", doc.getFieldValue(SolrConstants.FILENAME));
        }
        pageDocFileNameIddocMap.put((String) doc.getFieldValue(SolrConstants.FILENAME), iddoc);
        pageDocPhysIdIddocMap.put((String) doc.getFieldValue(SolrConstants.PHYSID), iddoc);
        pageDocsCounter.incrementAndGet();
        logger.debug("Page docs added: {}", pageDocsCounter);
    }
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:28,代码来源:SerializingSolrWriteStrategy.java

示例5: writeDocs

import org.apache.solr.common.SolrInputDocument; //导入方法依赖的package包/类
/**
 * @param aggregateHits
 * @throws IndexerException
 * @throws FatalIndexerException
 * @see de.intranda.digiverso.presentation.solr.model.ISolrWriteStrategy#writeDocs()
 * @should write all structure docs correctly
 * @should write all page docs correctly
 */
@Override
public void writeDocs(boolean aggregateRecords) throws IndexerException, FatalIndexerException {
    if (rootDoc == null) {
        throw new IndexerException("topDoc may not be null");
    }
    docsToAdd.add(rootDoc);
    String pi = (String) rootDoc.getFieldValue(SolrConstants.PI);
    for (int order : pageOrderMap.keySet()) {
        SolrInputDocument pageDoc = pageOrderMap.get(order);
        checkAndAddAccessCondition(pageDoc);
        docsToAdd.add(pageDoc);
        if (!pageDoc.containsKey(SolrConstants.PI_TOPSTRUCT) && pi != null) {
            pageDoc.addField(SolrConstants.PI_TOPSTRUCT, pi);
            logger.warn("Page document {} has no PI_TOPSTRUCT fields, adding now...", pageDoc.getFieldValue(SolrConstants.ORDER));
        }
        // Remove ALTO field (easier than removing all the logic involved in adding the ALTO field)
        if (pageDoc.containsKey(SolrConstants.ALTO)) {
            pageDoc.removeField(SolrConstants.ALTO);
        }
    }

    for (SolrInputDocument doc : docsToAdd) {
        if (doc.getFieldValue("GROUPFIELD") == null) {
            logger.error("Field has no GROUPFIELD: {}", doc.toString());
        }
        if (aggregateRecords) {
            if (doc.containsKey(SolrConstants.DEFAULT)) {
                rootDoc.addField(SolrConstants.SUPERDEFAULT, doc.getFieldValue(SolrConstants.DEFAULT));
            }
            //                if (doc.containsKey(SolrConstants.NORMDATATERMS)) {
            //                    rootDoc.addField(SolrConstants.NORMDATATERMS, doc.getFieldValue(SolrConstants.NORMDATATERMS));
            //                }
            if (doc.containsKey(SolrConstants.FULLTEXT)) {
                rootDoc.addField(SolrConstants.SUPERFULLTEXT, doc.getFieldValue(SolrConstants.FULLTEXT));
            }
        }
    }

    if (!docsToAdd.isEmpty()) {
        solrHelper.writeToIndex(docsToAdd);
        solrHelper.commit(SolrHelper.optimize);
        logger.debug("{} new doc(s) added.", docsToAdd.size());
    } else {
        throw new IndexerException("No docs to write");
    }
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:55,代码来源:LazySolrWriteStrategy.java

示例6: deskewAlto_handleMissingFilename

import org.apache.solr.common.SolrInputDocument; //导入方法依赖的package包/类
@Test
public void deskewAlto_handleMissingFilename() throws Exception {

    //        String filename = "AC04987957_00000124";
    String[] filenames = { "00000005.tif", "00225231.png" };

    int[] imageWidth = { 4966, 2794 };

    MetsIndexer indexer = new MetsIndexer(hotfolder);
    File dataFolder = new File("resources/test/alto_deskew");

    int i = 0;
    for (String filename : filenames) {

        String baseFilename = FilenameUtils.getBaseName(filename);

        File altoFile = new File(dataFolder, baseFilename + ".xml");
        String origAltoString = FileUtils.readFileToString(altoFile);
        File outputFolder = new File(dataFolder, "output");
        if (outputFolder.isDirectory()) {
            FileUtils.deleteDirectory(outputFolder);
        }
        outputFolder.mkdir();

        Map<String, Path> dataFolders = new HashMap<>();
        dataFolders.put(DataRepository.PARAM_MEDIA, Paths.get(dataFolder.getAbsolutePath()));

        SolrInputDocument doc = new SolrInputDocument();
        doc.setField(SolrConstants.ALTO, origAltoString);
        doc.setField(SolrConstants.WIDTH, "" + imageWidth[i]);
        //            doc.setField(SolrConstants.FILENAME, filename);

        MetsIndexer.deskewAlto(dataFolders, doc);
        String deskewedAltoString = (String) doc.getFieldValue(SolrConstants.ALTO);
        AltoDocument deskewedDoc = AltoDocument.getDocumentFromString(deskewedAltoString);
        FileUtils.writeStringToFile(new File(outputFolder, filename + ".xml"), deskewedAltoString, false);
        Word testWord = (Word) deskewedDoc.getFirstPage().getAllWordsAsList().get(1);
        Assert.assertNotNull(testWord);
        if (filename.equals("00000005.tif")) {
            Assert.assertEquals("Name", testWord.getContent());
            //                Assert.assertEquals(new Rectangle2D.Float(327, 765, 228, 54), testWord.getRect());
            Assert.assertEquals("Tag0", testWord.getAttributeValue("TAGREFS"));
            Assert.assertEquals("Tag0", deskewedDoc.getTags().getTags().getChild("NamedEntityTag", null).getAttributeValue("ID"));
        }

        i++;
    }
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:49,代码来源:MetsIndexerTest.java


注:本文中的org.apache.solr.common.SolrInputDocument.getFieldValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。