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


Java LeafReader.document方法代码示例

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


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

示例1: getValuesForTable

import org.apache.lucene.index.LeafReader; //导入方法依赖的package包/类
/**
 * Ritorna una collezione di stringhe come valori per popolare la tabella.
 * Viene usato sia dalla parte gui per far vedere i valori, sia in
 * inizializzazione del Segmenter per popolare fisicamente la tabella
 *
 * @param tableName nome della tabella
 * @return lista di valori
 */
public Collection<? extends String> getValuesForTable(String tableName) {
    BiMap<String, String> invFields = fieldsTable.inverse();
    String field = invFields.get(tableName);
    List<String> ret = new ArrayList<>();
    if (field != null) {
        if (reader == null) {
            openIndex();
        }
        try {
            final LeafReader ar = SlowCompositeReaderWrapper.wrap(reader);
            final int maxdoc = reader.maxDoc();
            for (int i = 0; i < maxdoc; i++) {
                Document doc = ar.document(i);
                String val = doc.get(field);
                if (val != null) {
                    if (val.trim().length() > 0) {
                        ret.add(val.trim().toLowerCase());
                    }
                }
            }
        } catch (Exception e) {
            LogGui.printException(e);
        }
    }
    return ret;
}
 
开发者ID:fiohol,项目名称:theSemProject,代码行数:35,代码来源:DataProviderConfiguration.java

示例2: updateCurrentDocument

import org.apache.lucene.index.LeafReader; //导入方法依赖的package包/类
private void updateCurrentDocument( int docID, LeafReader reader )
{
    try
    {
        currentDoc = reader.document( docID );
    }
    catch ( IOException e )
    {
        throw new RuntimeException( e );
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:12,代码来源:DocValuesCollector.java

示例3: getDocuments

import org.apache.lucene.index.LeafReader; //导入方法依赖的package包/类
/**
 * Ritorna l'elenco dei documenti sottoforma di stringhe contenuti
 * nell'indice di una particolare lingua. Viene usato dall'interfaccia
 * grafica del SEM GUI
 *
 * @param language lingua di cui si vogliono i documenti.
 * @return lista dei documenti sottoforma di stringhe per popolare la JTable
 * della GUI
 */
public List<String[]> getDocuments(String language) {
    List<String[]> rows = new ArrayList<>();
    try {
        String index = getIndexFolder(language);
        File fIndex = new File(index);
        if (fIndex.exists()) {
            IndexReader reader = DirectoryReader.open(getFolderDir(index));
            final LeafReader ar = SlowCompositeReaderWrapper.wrap(reader);
            Bits liveDocs = MultiFields.getLiveDocs(reader);
            final int maxdoc = reader.maxDoc();
            for (int i = 0; i < maxdoc; i++) {
                if (liveDocs != null && !liveDocs.get(i)) {
                    continue;
                }
                Document doc = ar.document(i);
                String[] row = new String[10];
                row[9] = "";
                row[0] = doc.get(IndexManager.UUID);
                row[1] = doc.get(IndexManager.BODY);
                row[2] = doc.get(IndexManager.TEXT);
                String level1 = (String) intern.intern(doc.get(IndexManager.LEVEL1_NAME));
                row[3] = level1;
                if (level1 != null) {
                    String level2 = (String) intern.intern(doc.get(IndexManager.LEVEL2_NAME));
                    if (level2 != null) {
                        row[4] = level2;
                        String level3 = (String) intern.intern(doc.get(IndexManager.LEVEL3_NAME));
                        if (level3 != null) {
                            row[5] = level3;
                            String level4 = (String) intern.intern(doc.get(IndexManager.LEVEL4_NAME));
                            if (level4 != null) {
                                row[6] = level4;
                                String level5 = (String) intern.intern(doc.get(IndexManager.LEVEL5_NAME));
                                if (level5 != null) {
                                    row[7] = level5;
                                    String level6 = (String) intern.intern(doc.get(IndexManager.LEVEL6_NAME));
                                    if (level6 != null) {
                                        row[8] = level6;
                                    }
                                }
                            }
                        }
                    }
                }
                if (i % 1000 == 0) {
                    LogGui.info("Read Progress... " + i);
                }
                rows.add(row);
            }
            reader.close();
        }
    } catch (Exception e) {
        LogGui.printException(e);
    }
    return rows;
}
 
开发者ID:fiohol,项目名称:theSemProject,代码行数:66,代码来源:MulticlassEngine.java

示例4: getDocumentsExcel

import org.apache.lucene.index.LeafReader; //导入方法依赖的package包/类
/**
 * Popola un excel con il contenuto dell'indice
 *
 * @since 1.2
 * @param language lingua indice
 * @param sheetResults excel da popolare
 * @param c1 valori della colonna kpi1
 * @param c2 valori della colonna kpi2
 */
public void getDocumentsExcel(String language, SXSSFSheet sheetResults, HashMap<String, String> c1, HashMap<String, String> c2) {
    try {
        int rownum = 1;
        String index = getIndexFolder(language);
        IndexReader reader = DirectoryReader.open(getFolderDir(index));
        final LeafReader ar = SlowCompositeReaderWrapper.wrap(reader);
        Bits liveDocs = MultiFields.getLiveDocs(reader);
        final int maxdoc = reader.maxDoc();
        for (int i = 0; i < maxdoc; i++) {
            if (liveDocs != null && !liveDocs.get(i)) {
                continue;
            }
            Document doc = ar.document(i);
            SXSSFRow row = sheetResults.createRow(rownum++);
            String text = doc.get(IndexManager.TEXT);
            if (text == null) {
                text = "";
            }
            row.createCell(6).setCellValue(text);
            row.createCell(7).setCellValue(doc.get(IndexManager.BODY));
            String id = doc.get(IndexManager.UUID);
            String c1v = c1.get(id);
            String c2v = c2.get(id);
            if (c1v != null) {
                row.createCell(8).setCellValue(c1v);
            }
            if (c2v != null) {
                row.createCell(9).setCellValue(c2v);
            }
            String level1 = (String) intern.intern(doc.get(IndexManager.LEVEL1_NAME));
            row.createCell(0).setCellValue(level1);
            if (level1 != null) {
                String level2 = (String) intern.intern(doc.get(IndexManager.LEVEL2_NAME));
                if (level2 != null) {
                    row.createCell(1).setCellValue(level2);
                    String level3 = (String) intern.intern(doc.get(IndexManager.LEVEL3_NAME));
                    if (level3 != null) {
                        row.createCell(2).setCellValue(level3);
                        String level4 = (String) intern.intern(doc.get(IndexManager.LEVEL4_NAME));
                        if (level4 != null) {
                            row.createCell(3).setCellValue(level4);
                            String level5 = (String) intern.intern(doc.get(IndexManager.LEVEL5_NAME));
                            if (level5 != null) {
                                row.createCell(4).setCellValue(level5);
                                String level6 = (String) intern.intern(doc.get(IndexManager.LEVEL6_NAME));
                                if (level6 != null) {
                                    row.createCell(5).setCellValue(level6);
                                }
                            }
                        }
                    }
                }
            }
            if (i % 1000 == 0) {
                LogGui.info("Read Progress... " + i);
            }
        }
        reader.close();
    } catch (Exception e) {
        LogGui.printException(e);
    }
}
 
开发者ID:fiohol,项目名称:theSemProject,代码行数:72,代码来源:MulticlassEngine.java


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