Top Description Constructors Methods
org.apache.pdfbox.examples.lucene

public final Class IndexPDFFiles

extends Object
Class Inheritance
Imports
java.io.File, .FileInputStream, .FileNotFoundException, .IOException, java.util.Date, org.apache.lucene.analysis.Analyzer, org.apache.lucene.analysis.standard.StandardAnalyzer, org.apache.lucene.document.Document, org.apache.lucene.index.IndexWriter, org.apache.lucene.index.IndexWriterConfig, org.apache.lucene.index.IndexWriterConfig.OpenMode, org.apache.lucene.index.Term, org.apache.lucene.store.Directory, org.apache.lucene.store.FSDirectory

Index all pdf files under a directory.

This is a command-line application demonstrating simple Lucene indexing. Run it with no command-line arguments for usage information.

It's based on a demo provided by the lucene project.

Important Note

The pom.xml uses an outdated lucene version. Replace that version with the latest version to avoid security risks like CVE-2024-45772.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
indexDocs(org.apache.lucene.index.IndexWriter
Writer to the index where the given file/dir info will be stored
writer
,
File
The file to index, or the directory to recurse into to find files to index
file
)

Indexes the given file using the given writer, or if a directory is given, recurses over files and directories found under the given directory.

public static void
main(String[]
command line arguments
args
)

Index all text files under a directory.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

IndexPDFFilesback to summary
private IndexPDFFiles()

Method Detail

indexDocsback to summary
pack-priv static void indexDocs(org.apache.lucene.index.IndexWriter writer, File file) throws IOException

Indexes the given file using the given writer, or if a directory is given, recurses over files and directories found under the given directory.

Note

This method indexes one document per input file. This is slow. For good throughput, put multiple documents into your input file(s). An example of this is in the benchmark module, which can create "line doc" files, one document per line, using the WriteLineDocTask.

Parameters
writer:org.apache.lucene.index.IndexWriter

Writer to the index where the given file/dir info will be stored

file:File

The file to index, or the directory to recurse into to find files to index

Exceptions
IOException:
If there is a low-level I/O error
mainback to summary
public static void main(String[] args)

Index all text files under a directory.

Parameters
args:String[]

command line arguments