Interface BBjAdminDocumentIndex
- All Superinterfaces:
BBjAdminCommitPropertyWriter
,BBjAdminCommitWriter
,BBjAdminPropertyReader
,BBjAdminPropertyWriter
,Remote
- All Known Subinterfaces:
BBjAdminElasticsearchDocumentIndex
,BBjAdminLuceneDocumentIndex
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:
BBj Example
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()
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
List of directories to be monitored for documents.static final String
CURRENTLY NOT IMPLEMENTED.static final String
List of wildcard filters to use to filter specifically invalid files so they are not indexed.static final String
List of wildcard filters to use to filter valid files to be indexed.static final String
Used on call to BBjAdminBase.createDocumentIndex() to specify a Lucene archive.static final String
Name of the document index.static final String
Number of seconds the document index waits before scanning the document locations for new or modified documents. -
Method Summary
Modifier and TypeMethodDescriptionaddDocument
(URI p_uri) Adds the document at the specified URI to the document index.createDocumentLocation
(String p_directory, boolean p_recursive) Creates a new instance of a BBjAdminDocumentLocation.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.Executes a search on this document archive and returns a list of the documents that match the search query.searchWithPreview
(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.Methods inherited from interface com.basis.api.admin.BBjAdminCommitPropertyWriter
getChangedProperties, getClearedProperties, getOriginalProperties
Methods inherited from interface com.basis.api.admin.BBjAdminCommitWriter
commit, rollback
Methods inherited from interface com.basis.api.admin.BBjAdminPropertyReader
checkValueEqual, contains, contains, getBoolean, getDouble, getInt, getList, getLong, getProperties, getString, getType, getTypes, getValue
Methods inherited from interface com.basis.api.admin.BBjAdminPropertyWriter
addType, canAddNewProperties, canClear, clear, clearProperties, clearProperty, getReadOnly, hasChanged, isReadOnly, setBoolean, setDouble, setInt, setList, setLong, setProperties, setString, setValue
-
Field Details
-
NAME
Name of the document index.- See Also:
-
DOCUMENT_LOCATIONS
List of directories to be monitored for documents. Documents will be indexed when they are added to a monitored directory or when a document in a direcotry is modified.- See Also:
-
INCLUDE_FILTERS
List of wildcard filters to use to filter valid files to be indexed.- See Also:
-
EXCLUDE_FILTERS
List of wildcard filters to use to filter specifically invalid files so they are not indexed.- See Also:
-
SCAN_FREQUENCY
Number of seconds the document index waits before scanning the document locations for new or modified documents.- See Also:
-
LUCENE_TYPE
Used on call to BBjAdminBase.createDocumentIndex() to specify a Lucene archive.- See Also:
-
ELASTICSEARCH_TYPE
CURRENTLY NOT IMPLEMENTED. Used on call to BBjAdminBase.createDocumentIndex() to specify an elasticsearch archive.- See Also:
-
-
Method Details
-
search
Executes a search on this document archive and returns a list of the documents that match the search query.- Parameters:
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.- Returns:
- Search result matches.
- Throws:
BBjAdminException
-
searchWithPreview
BBjAdminMap<String,String> searchWithPreview(String p_searchString, int p_maxPreviewLength, int p_maxResults) throws BBjAdminException Executes a search on this document archive and returns a list of the documents that match the search query. The returned Map contains a map of filename to preview text. Preview is plain text beginning from the beginning of the document.- Parameters:
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.- Returns:
- Search result matches.
- Throws:
BBjAdminException
-
addDocument
Adds the document at the specified URI to the document index. The URI can be an HTTP or HTTPS URL or a file:// format reference to a file on the local drive.- Parameters:
p_uri
- Location of the document to add to the index.- Returns:
- Location of the document.
- Throws:
BBjAdminException
-
setPaused
Pauses/resumes the indexing of this document index. When an index is paused, the thread continues to run but it does not index any additional documents until resumed.- Parameters:
p_paused
-- Throws:
BBjAdminException
-
isPaused
Returns the paused state of this document index.- Returns:
- True if the index is paused.
- Throws:
BBjAdminException
-
createDocumentLocation
BBjAdminDocumentLocation createDocumentLocation(String p_directory, boolean p_recursive) throws BBjAdminException Creates a new instance of a BBjAdminDocumentLocation. This should be used instead of trying to create an instance of BBjAdminLocalDocumentLocation explicitly.- Parameters:
p_directory
-p_recursive
-- Returns:
- The new BBjAdminDocumentLocation instance.
- Throws:
BBjAdminException
-
getDescriptiveProperties
Used primarily by GUI applications like the Enterprise Manager to dynamically generate an admin UI. To get property values for general purposes, you should call the getXXX() methods.- Returns:
- BBjAdminList containing BBjAdminProperty objects for each available property.
- Throws:
BBjAdminException
-
setDescriptiveProperties
void setDescriptiveProperties(BBjAdminList<BBjAdminProperty> p_descriptiveProps) throws BBjAdminException Used primarily by GUI applications like the Enterprise Manager to dynamically generate an admin UI. To set property values for general purposes, you should call the setXXX() methods.- Throws:
BBjAdminException
-