Search and Index Essentials
Searching for Text in PDF Documents
11
Searching Across Multiple PDF Documents
Searching all PDF Files in a Specific Location
To search all the PDF files within a folder, set the
cWhere
parameter in the
search
object’s
query
method to
Folder
. In the following example, all documents in
/C/MyFolder
will be searched for the word "Acrobat":
search.query("Acrobat", "Folder", "/C/MyFolder");
Using Advanced Search Options for Multiple Document Searches
In addition to the advanced options for matching phrases, using stemming, and using
proximity, it is also possible to specify whether the search should be case-sensitive,
whether to match whole words, set the maximum number of documents to be returned as
part of a query, and whether to refine the results of the previous query.
To specify that a search should be case sensitive, set the
search
object’s
matchCase
property to
true
. For example, the following code matches "Acrobat" but not "acrobat":
search.matchCase = true;
search.query("Acrobat", "Folder", "/C/MyFolder");
To specify that the search should only identify occurrences of complete words, set the
search
object’s
matchWholeWord
property to
true
. For example, the following code
matches "stick", but not "tick" or "sticky":
search.matchWholeWord = true;
search.query("stick", "Folder", "/C/MyFolder");
To set the maximum number of documents to be returned as part of a query, set the
search
object’s
maxDocs
property to the desired number (the default is 100). For
example, the following code limits the number of documents to be searched to 5:
search.maxDocs = 5;
To refine the results of the previous query, set the
search
object’s
refine
property to
true
, as shown in the following code:
search.refine = true;
Acrobat JavaScript Scripting Guide
195