List of usage examples for org.apache.lucene.index IndexReader document
public final Document document(int docID, Set<String> fieldsToLoad) throws IOException
From source file:org.modeshape.search.lucene.query.ComparePathQuery.java
License:Open Source License
/** * {@inheritDoc}//from w ww . j a v a 2s .c o m * * @see org.modeshape.search.lucene.query.CompareQuery#readFromDocument(org.apache.lucene.index.IndexReader, int) */ @Override protected Path readFromDocument(IndexReader reader, int docId) throws IOException { Document doc = reader.document(docId, fieldSelector); String valueString = doc.get(fieldName); if (!caseSensitive) valueString = valueString.toLowerCase(); return valueTypeFactory.create(valueString); }
From source file:org.netbeans.modules.jackpot30.backend.impl.spi.StatisticsGenerator.java
License:Open Source License
public static Map<String, Long> generateStatistics(IndexReader r) throws IOException { statistics = new HashMap<String, Long>(); Collection<? extends StatisticsGenerator> generators = Lookup.getDefault() .lookupAll(StatisticsGenerator.class); int maxDocs = r.maxDoc(); for (int d = 0; d < maxDocs; d++) { Document doc = r.document(d, new FieldSelector() { @Override/*from w ww .ja v a2 s . c o m*/ public FieldSelectorResult accept(String string) { return FieldSelectorResult.LAZY_LOAD; } }); for (StatisticsGenerator sg : generators) { sg.amendStatistics(r, doc); } } Map<String, Long> result = statistics; statistics = null; return result; }