public interface BBjAdminDocumentIndex extends BBjAdminCommitPropertyWriter
A single document index available to BBj Services. A document index is a way to configure a directory of files to be automatically indexed in a Lucene index when a new file is added to the directory or if a document is modified. The text of each supported document in the monitored directory(s) will be extracted from the document and indexed. The file itself is not indexed. The document index stores a reference to the file from which the text was derived.
Once a document index has indexed documents, you can query the index for documents that match Lucene Query Syntax searches. See Apache Lucene - Query Parser Syntax for information on the available query options. This robust query syntax provides a way to perform complex searching of an entire document archive with lightning fast performance.
The easiest way to create a document index is using the Enterprise Manager. However, you can also create them using this Admin API. The following code sample shows an example of creating a document index and then querying that index for documents that match a variety of queries:
declare BBjAdminBase api!
declare BBjAdminList docLocations!
declare BBjAdminList includeFilters!
declare BBjAdminList results!
declare BBjAdminMap resultsMap!
declare BBjAdminDocumentIndex idx!
declare BBjAdminDocumentLocation docLoc!
REM Get the API instance
api! = BBjAdminFactory.getBBjAdmin("admin", "admin123")
idx! = api!.createDocumentIndex("MyIndex", BBjAdminDocumentIndex.LUCENE_TYPE)
docLocations! = api!.createBBjAdminList()
docLoc! = idx!.createDocumentLocation("/path/to/myDocumentsToIndex", Boolean.TRUE)
docLocations!.add(docLoc!)
idx!.setList(BBjAdminDocumentIndex.DOCUMENT_LOCATIONS, docLocations!)
includeFilters! = api!.createBBjAdminList()
includeFilters!.add("*.pdf")
includeFilters!.add("*.doc")
idx!.setList(BBjAdminDocumentIndex.INCLUDE_FILTERS, includeFilters!)
REM Set it to scan for new or modified files every 10 seconds. Set to 0 and it won't
REM scan automatically, you have to add them manually.
idx!.setInt(BBjAdminDocumentIndex.SCAN_FREQUENCY, 10)
REM Set the location where you want the Lucene index to be created.
idx!.setString(BBjAdminLuceneDocumentIndex.INDEX_LOCATION, "/path/to/luceneindex")
REM True if you want them to be able to search using a wildcard as first character
REM of a search term. This can be slower. Lucene actually defaults to NOT allow
REM this. However, setting enabled makes it easier for your users to understand
REM queries. Turn it off and users get an error if they try to search using wildcard (*) in their queries.
idx!.setBoolean(BBjAdminLuceneDocumentIndex.ALLOW_LEADING_WILDCARD, Boolean.TRUE)
REM Save the document index definition.
idx!.commit()
REM Now query the document index and return the name of matching documents.
idx! = api!.getDocumentIndex("MyIndex")
results! = idx!.search("banana*", 0)
for r = 0 to results!.size() - 1
PRINT "Match: " + results!.get(r)
next r
REM Query the document index and also return preview text.
maxPreviewLen = 250
resultsMap! = idx!.searchWithPreview("banana*", maxPreviewLen, 0)
entries! = resultsMap!.entrySet().iterator()
while entries!.hasNext()
entry! = entries.next()
PRINT "Match: " + entry!.getKey()
PRINT "Preview: " + entry!.getValue()
PRINT "===================================="
wend
REM Release the Admin API instance.
api!.release()
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DOCUMENT_LOCATIONS
List of directories to be monitored for documents.
|
static java.lang.String |
ELASTICSEARCH_TYPE
CURRENTLY NOT IMPLEMENTED.
|
static java.lang.String |
EXCLUDE_FILTERS
List of wildcard filters to use to filter specifically invalid files so they are not indexed.
|
static java.lang.String |
INCLUDE_FILTERS
List of wildcard filters to use to filter valid files to be indexed.
|
static java.lang.String |
LUCENE_TYPE
Used on call to BBjAdminBase.createDocumentIndex() to specify a Lucene archive.
|
static java.lang.String |
NAME
Name of the document index.
|
static java.lang.String |
SCAN_FREQUENCY
Number of seconds the document index waits before scanning the document locations for new
or modified documents.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
addDocument(java.net.URI p_uri)
Adds the document at the specified URI to the document index.
|
BBjAdminDocumentLocation |
createDocumentLocation(java.lang.String p_directory,
boolean p_recursive)
Creates a new instance of a BBjAdminDocumentLocation.
|
BBjAdminList<BBjAdminProperty> |
getDescriptiveProperties()
Used primarily by GUI applications like the Enterprise Manager to dynamically generate
an admin UI.
|
boolean |
isPaused()
Returns the paused state of this document index.
|
BBjAdminList<java.lang.String> |
search(java.lang.String p_searchString,
int p_maxResults)
Executes a search on this document archive and returns a list of the documents
that match the search query.
|
BBjAdminMap<java.lang.String,java.lang.String> |
searchWithPreview(java.lang.String p_searchString,
int p_maxPreviewLength,
int p_maxResults)
Executes a search on this document archive and returns a list of the documents
that match the search query.
|
void |
setDescriptiveProperties(BBjAdminList<BBjAdminProperty> p_descriptiveProps)
Used primarily by GUI applications like the Enterprise Manager to dynamically generate
an admin UI.
|
void |
setPaused(boolean p_paused)
Pauses/resumes the indexing of this document index.
|
getChangedProperties, getClearedProperties, getOriginalProperties
addType, canAddNewProperties, canClear, clear, clearProperties, clearProperty, getReadOnly, hasChanged, isReadOnly, setBoolean, setDouble, setInt, setList, setLong, setProperties, setString, setValue
checkValueEqual, contains, contains, getBoolean, getDouble, getInt, getList, getLong, getProperties, getString, getType, getTypes, getValue
commit, rollback
static final java.lang.String NAME
static final java.lang.String DOCUMENT_LOCATIONS
static final java.lang.String INCLUDE_FILTERS
static final java.lang.String EXCLUDE_FILTERS
static final java.lang.String SCAN_FREQUENCY
static final java.lang.String LUCENE_TYPE
static final java.lang.String ELASTICSEARCH_TYPE
BBjAdminList<java.lang.String> search(java.lang.String p_searchString, int p_maxResults) throws BBjAdminException
p_searchString
- Search string in a format understood by the index back end.p_maxResults
- Maximum number of results to return. 0 means no limit.BBjAdminException
BBjAdminMap<java.lang.String,java.lang.String> searchWithPreview(java.lang.String p_searchString, int p_maxPreviewLength, int p_maxResults) throws BBjAdminException
p_searchString
- Search string in a format understood by the index back end.p_maxResults
- Maximum number of results to return. 0 means no limit.BBjAdminException
java.lang.String addDocument(java.net.URI p_uri) throws BBjAdminException
p_uri
- Location of the document to add to the index.BBjAdminException
void setPaused(boolean p_paused) throws BBjAdminException
p_paused
- BBjAdminException
boolean isPaused() throws BBjAdminException
BBjAdminException
BBjAdminDocumentLocation createDocumentLocation(java.lang.String p_directory, boolean p_recursive) throws BBjAdminException
p_directory
- p_recursive
- BBjAdminException
BBjAdminList<BBjAdminProperty> getDescriptiveProperties() throws BBjAdminException
BBjAdminException
void setDescriptiveProperties(BBjAdminList<BBjAdminProperty> p_descriptiveProps) throws BBjAdminException
BBjAdminException