11
Search and Index Essentials
Indexing Multiple PDF Documents
To build an index, first invoke the
catalog
object’s
getIndex
method to retrieve the
index
object. This method accepts a parameter containing the path of the
index
object.
Then invoke the
index
object’s
build
method, which returns a
catalogJob
object. The
method accepts two parameters:
●
cExpr
: an Acrobat JavaScript expression executed once the build operation is
complete
●
bRebuildAll
: indicates whether to perform a clean build in which the existing index
is first deleted and then completely built
Finally, the returned
catalogJob
object contains three properties providing useful
information about the indexing job:
●
●
●
path
: the device-independent path of the index
type
: the type of indexing operation (
Build
,
Rebuild
, or
Delete
)
status
: the status of the indexing operation (
Pending
,
Processing
,
Completed
,
or
CompletedWithErrors
)
In the code shown below, the index
myIndex
is completely rebuilt, after which its status is
reported:
// Retrieve the Index object
var idx = catalog.getIndex("/C/myIndex.pdx");
// Build the Index
var job = idx.build("app.alert(‘Index build’);", true);
// Confirm the path of the rebuilt index:
console.println("Path of rebuilt index: " + job.path);
// Confirm that the index was rebuilt:
console.println("Type of operation: " + job.type);
// Report the job status
console.println("Status: " + job.status);
198
Acrobat JavaScript Scripting Guide