Interface BBjAdminDocumentIndex

All Superinterfaces:
BBjAdminCommitPropertyWriter, BBjAdminCommitWriter, BBjAdminPropertyReader, BBjAdminPropertyWriter, Remote
All Known Subinterfaces:
BBjAdminElasticsearchDocumentIndex, BBjAdminLuceneDocumentIndex

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:

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 Details

    • NAME

      static final String NAME
      Name of the document index.
      See Also:
    • DOCUMENT_LOCATIONS

      static final String 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

      static final String INCLUDE_FILTERS
      List of wildcard filters to use to filter valid files to be indexed.
      See Also:
    • EXCLUDE_FILTERS

      static final String EXCLUDE_FILTERS
      List of wildcard filters to use to filter specifically invalid files so they are not indexed.
      See Also:
    • SCAN_FREQUENCY

      static final String SCAN_FREQUENCY
      Number of seconds the document index waits before scanning the document locations for new or modified documents.
      See Also:
    • LUCENE_TYPE

      static final String LUCENE_TYPE
      Used on call to BBjAdminBase.createDocumentIndex() to specify a Lucene archive.
      See Also:
    • ELASTICSEARCH_TYPE

      static final String ELASTICSEARCH_TYPE
      CURRENTLY NOT IMPLEMENTED. Used on call to BBjAdminBase.createDocumentIndex() to specify an elasticsearch archive.
      See Also:
  • Method Details

    • search

      BBjAdminList<String> search(String p_searchString, int p_maxResults) throws BBjAdminException
      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

      String addDocument(URI p_uri) throws BBjAdminException
      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

      void setPaused(boolean p_paused) throws BBjAdminException
      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

      boolean isPaused() throws BBjAdminException
      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

      BBjAdminList<BBjAdminProperty> getDescriptiveProperties() throws BBjAdminException
      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