Java Code Examples for org.apache.lucene.index.DirectoryReader#directory()
The following examples show how to use
org.apache.lucene.index.DirectoryReader#directory() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: SearchServices File: AlfrescoLukeRequestHandler.java License: GNU Lesser General Public License v3.0 | 6 votes |
public static SimpleOrderedMap<Object> getIndexInfo(DirectoryReader reader) throws IOException { Directory dir = reader.directory(); SimpleOrderedMap<Object> indexInfo = new SimpleOrderedMap<>(); indexInfo.add("numDocs", reader.numDocs()); indexInfo.add("maxDoc", reader.maxDoc()); indexInfo.add("deletedDocs", reader.maxDoc() - reader.numDocs()); indexInfo.add("indexHeapUsageBytes", getIndexHeapUsed(reader)); indexInfo.add("version", reader.getVersion()); // TODO? Is this // different then: // IndexReader.getCurrentVersion( // dir )? indexInfo.add("segmentCount", reader.leaves().size()); indexInfo.add("current", reader.isCurrent()); indexInfo.add("hasDeletions", reader.hasDeletions()); indexInfo.add("directory", dir); indexInfo.add("userData", reader.getIndexCommit().getUserData()); String s = reader.getIndexCommit().getUserData() .get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY); if (s != null) { indexInfo.add("lastModified", new Date(Long.parseLong(s))); } return indexInfo; }
Example 2
Source Project: lucene-solr File: LukeModel.java License: Apache License 2.0 | 6 votes |
protected LukeModel(IndexReader reader) { this.reader = Objects.requireNonNull(reader); if (reader instanceof DirectoryReader) { DirectoryReader dr = (DirectoryReader) reader; this.dir = dr.directory(); try { this.commit = dr.getIndexCommit(); } catch (IOException e) { throw new LukeException(e.getMessage(), e); } } else { this.dir = null; this.commit = null; } this.liveDocs = IndexUtils.getLiveDocs(reader); }
Example 3
Source Project: lucene-solr File: LukeRequestHandler.java License: Apache License 2.0 | 6 votes |
public static SimpleOrderedMap<Object> getIndexInfo(DirectoryReader reader) throws IOException { Directory dir = reader.directory(); SimpleOrderedMap<Object> indexInfo = new SimpleOrderedMap<>(); indexInfo.add("numDocs", reader.numDocs()); indexInfo.add("maxDoc", reader.maxDoc()); indexInfo.add("deletedDocs", reader.maxDoc() - reader.numDocs()); indexInfo.add("indexHeapUsageBytes", getIndexHeapUsed(reader)); indexInfo.add("version", reader.getVersion()); // TODO? Is this different then: IndexReader.getCurrentVersion( dir )? indexInfo.add("segmentCount", reader.leaves().size()); indexInfo.add("current", closeSafe( reader::isCurrent)); indexInfo.add("hasDeletions", reader.hasDeletions() ); indexInfo.add("directory", dir ); IndexCommit indexCommit = reader.getIndexCommit(); String segmentsFileName = indexCommit.getSegmentsFileName(); indexInfo.add("segmentsFile", segmentsFileName); indexInfo.add("segmentsFileSizeInBytes", getSegmentsFileLength(indexCommit)); Map<String,String> userData = indexCommit.getUserData(); indexInfo.add("userData", userData); String s = userData.get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY); if (s != null) { indexInfo.add("lastModified", new Date(Long.parseLong(s))); } return indexInfo; }
Example 4
Source Project: lucene-solr File: DirectUpdateHandlerTest.java License: Apache License 2.0 | 4 votes |
@Test public void testPrepareCommit() throws Exception { assertU(adoc("id", "999")); assertU(optimize("maxSegments", "1")); // make sure there's just one segment assertU(commit()); // commit a second time to make sure index files aren't still referenced by the old searcher SolrQueryRequest sr = req(); DirectoryReader r = sr.getSearcher().getIndexReader(); Directory d = r.directory(); if (log.isInfoEnabled()) { log.info("FILES before addDoc={}", Arrays.asList(d.listAll())); } assertU(adoc("id", "1")); int nFiles = d.listAll().length; if (log.isInfoEnabled()) { log.info("FILES before prepareCommit={}", Arrays.asList(d.listAll())); } updateJ("", params("prepareCommit", "true")); if (log.isInfoEnabled()) { log.info("FILES after prepareCommit={}", Arrays.asList(d.listAll())); } assertTrue( d.listAll().length > nFiles); // make sure new index files were actually written assertJQ(req("q", "id:1") , "/response/numFound==0" ); updateJ("", params("rollback","true")); assertU(commit()); assertJQ(req("q", "id:1") , "/response/numFound==0" ); assertU(adoc("id","1")); updateJ("", params("prepareCommit","true")); assertJQ(req("q", "id:1") , "/response/numFound==0" ); assertU(commit()); assertJQ(req("q", "id:1") , "/response/numFound==1" ); sr.close(); }
Example 5
Source Project: incubator-retired-blur File: BlurInputFormatSplitCommand.java License: Apache License 2.0 | 4 votes |
private Directory getDirectory(IndexReader indexReader) { DirectoryReader directoryReader = (DirectoryReader) indexReader; return directoryReader.directory(); }
Example 6
Source Project: lucene-solr File: CommitsImpl.java License: Apache License 2.0 | 2 votes |
/** * Constructs a CommitsImpl that holds the {@link Directory} wrapped in the given {@link DirectoryReader}. * * @param reader - the index reader * @param indexPath - the path to index directory */ public CommitsImpl(DirectoryReader reader, String indexPath) { super(reader.directory()); this.indexPath = indexPath; this.commitMap = initCommitMap(); }