com.xpn.xwiki.plugin.lucene
Class LucenePluginApi

java.lang.Object
  extended by com.xpn.xwiki.api.Api
      extended by com.xpn.xwiki.plugin.PluginApi<LucenePlugin>
          extended by com.xpn.xwiki.plugin.lucene.LucenePluginApi

public class LucenePluginApi
extends com.xpn.xwiki.plugin.PluginApi<LucenePlugin>

This plugin allows index based search in the contents of Wiki Pages and their attachments, as far as any text can be extracted from them. Text can be extracted from OpenOffice Writer, MSWord, PDF, XML/XHTML, plain text, etc. Text extraction is done with the help of various third party libs such as Apache POI and PDFBox and some classes from the Daisy project.

This is the main interface for using the Lucene Plugin. It acts as a facade to the LucenePlugin class.

Version:
$Id: LucenePluginApi.java 29609 2010-06-21 13:27:14Z tmortagne $

Field Summary
static int REBUILD_IN_PROGRESS
          Return value for rebuildIndex() meaning that another rebuild is already in progress.
static int REBUILD_NOT_ALLOWED
          Return value for rebuildIndex() meaning that the caller does not have admin rights.
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Constructor Summary
LucenePluginApi(LucenePlugin plugin, com.xpn.xwiki.XWikiContext context)
           
 
Method Summary
 long getLuceneDocCount()
           
 long getQueueSize()
           
 SearchResults getSearchResults(java.lang.String query, java.lang.String languages)
          Searches the configured Indexes using the specified lucene query for documents in the given languages.
 SearchResults getSearchResults(java.lang.String query, java.lang.String[] sortField, java.lang.String languages)
          Searches the configured Indexes using the specified lucene query for documents in the given languages.
 SearchResults getSearchResults(java.lang.String query, java.lang.String[] sortField, java.lang.String virtualWikiNames, java.lang.String languages)
          Searches the configured Indexes using the specified lucene query for documents in the given languages belonging to one of the given virtual wikis.
 SearchResults getSearchResults(java.lang.String query, java.lang.String sortField, java.lang.String languages)
          Searches the configured Indexes using the specified lucene query for documents in the given languages.
 SearchResults getSearchResults(java.lang.String query, java.lang.String sortField, java.lang.String virtualWikiNames, java.lang.String languages)
          Searches the configured Indexes using the specified lucene query for documents in the given languages belonging to one of the given virtual wikis.
 SearchResults getSearchResultsFromIndexes(java.lang.String query, java.lang.String[] sortField, java.lang.String indexDirs, java.lang.String languages)
          Searches the named indexes using the given query for documents in the given languages
 SearchResults getSearchResultsFromIndexes(java.lang.String query, java.lang.String indexDirs, java.lang.String languages)
          Searches the named indexes using the given query for documents in the given languages
 SearchResults getSearchResultsFromIndexes(java.lang.String query, java.lang.String sortField, java.lang.String indexDirs, java.lang.String languages)
          Searches the named indexes using the given query for documents in the given languages
 int rebuildIndex()
          Starts a rebuild of the whole index.
 int rebuildIndex(com.xpn.xwiki.api.XWiki wiki, com.xpn.xwiki.api.Context context)
          Deprecated. use rebuildIndex without context values
 int startIndex(java.util.Collection<java.lang.String> wikis, java.lang.String hqlFilter, boolean clearIndex, boolean onlyNew)
          Starts a rebuild of the whole index.
 
Methods inherited from class com.xpn.xwiki.plugin.PluginApi
getInternalPlugin, getPlugin, getProtectedPlugin, setPlugin
 
Methods inherited from class com.xpn.xwiki.api.Api
checkProgrammingRights, convert, convert, getXWikiContext, hasAccessLevel, hasAdminRights, hasProgrammingRights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REBUILD_NOT_ALLOWED

public static final int REBUILD_NOT_ALLOWED
Return value for rebuildIndex() meaning that the caller does not have admin rights.

See Also:
Constant Field Values

REBUILD_IN_PROGRESS

public static final int REBUILD_IN_PROGRESS
Return value for rebuildIndex() meaning that another rebuild is already in progress.

See Also:
Constant Field Values
Constructor Detail

LucenePluginApi

public LucenePluginApi(LucenePlugin plugin,
                       com.xpn.xwiki.XWikiContext context)
Method Detail

rebuildIndex

public int rebuildIndex()
Starts a rebuild of the whole index.

Returns:
number of documents scheduled for indexing. -1 in case of errors

startIndex

public int startIndex(java.util.Collection<java.lang.String> wikis,
                      java.lang.String hqlFilter,
                      boolean clearIndex,
                      boolean onlyNew)
Starts a rebuild of the whole index.

Parameters:
hqlFilter -
clearIndex -
onlyNew -
Returns:
number of documents scheduled for indexing. -1 in case of errors

rebuildIndex

@Deprecated
public int rebuildIndex(com.xpn.xwiki.api.XWiki wiki,
                                   com.xpn.xwiki.api.Context context)
Deprecated. use rebuildIndex without context values

Starts a rebuild of the whole index.

Parameters:
wiki -
context -
Returns:
Number of documents scheduled for indexing. -1 in case of errors

getQueueSize

public long getQueueSize()
Returns:
the remaining number of documents to index in the queue.

getLuceneDocCount

public long getLuceneDocCount()
Returns:
the number of documents Lucene index writer.

getSearchResultsFromIndexes

public SearchResults getSearchResultsFromIndexes(java.lang.String query,
                                                 java.lang.String indexDirs,
                                                 java.lang.String languages)
Searches the named indexes using the given query for documents in the given languages

Parameters:
query - the query entered by the user
indexDirs - comma separated list of lucene index directories to search in
languages - comma separated list of language codes to search in, may be null to search all languages reference to xwiki
Returns:
SearchResults instance containing the results.

getSearchResults

public SearchResults getSearchResults(java.lang.String query,
                                      java.lang.String languages)
Searches the configured Indexes using the specified lucene query for documents in the given languages.

With virtual wikis enabled in your xwiki installation this will deliver results from all virtuall wikis. For searching in a subset of your virtual wikis see #getSearchResults(String, String, String, com.xpn.xwiki.api.XWiki)

Parameters:
query - query entered by the user
languages - comma separated list of language codes to search in, may be null to search all languages. Language codes can be:
  • default for content having no specific language information
  • lower case 2-letter language codes like en, de as used by xwiki
Returns:
a SearchResults instance containing the results.

getSearchResultsFromIndexes

public SearchResults getSearchResultsFromIndexes(java.lang.String query,
                                                 java.lang.String sortField,
                                                 java.lang.String indexDirs,
                                                 java.lang.String languages)
Searches the named indexes using the given query for documents in the given languages

Parameters:
query - the query entered by the user
sortField - sortField to sort on
indexDirs - comma separated list of lucene index directories to search in
languages - comma separated list of language codes to search in, may be null to search all languages reference to xwiki
Returns:
SearchResults instance containing the results.

getSearchResultsFromIndexes

public SearchResults getSearchResultsFromIndexes(java.lang.String query,
                                                 java.lang.String[] sortField,
                                                 java.lang.String indexDirs,
                                                 java.lang.String languages)
Searches the named indexes using the given query for documents in the given languages

Parameters:
query - the query entered by the user
sortField - sortField(s) to sort on
indexDirs - comma separated list of lucene index directories to search in
languages - comma separated list of language codes to search in, may be null to search all languages reference to xwiki
Returns:
SearchResults instance containing the results.

getSearchResults

public SearchResults getSearchResults(java.lang.String query,
                                      java.lang.String sortField,
                                      java.lang.String languages)
Searches the configured Indexes using the specified lucene query for documents in the given languages.

With virtual wikis enabled in your xwiki installation this will deliver results from all virtuall wikis. For searching in a subset of your virtual wikis see #getSearchResults(String, String, String, com.xpn.xwiki.api.XWiki)

Parameters:
query - query entered by the user
sortField - field to use to sort the results list (ex: date, author)
languages - comma separated list of language codes to search in, may be null to search all languages. Language codes can be:
  • default for content having no specific language information
  • lower case 2-letter language codes like en, de as used by xwiki
Returns:
a SearchResults instance containing the results.

getSearchResults

public SearchResults getSearchResults(java.lang.String query,
                                      java.lang.String sortField,
                                      java.lang.String virtualWikiNames,
                                      java.lang.String languages)
Searches the configured Indexes using the specified lucene query for documents in the given languages belonging to one of the given virtual wikis.

Using this method only makes sense with virtual wikis enabled. Otherwise use #getSearchResults(String, String, com.xpn.xwiki.api.XWiki) instead.

Parameters:
query - query entered by the user
sortField - field to sort on
virtualWikiNames - Names of the virtual wikis to search in. May be null for global search.
languages - comma separated list of language codes to search in, may be null to search all languages. Language codes can be:
  • default for content having no specific language information
  • lower case 2-letter language codes like en, de as used by xwiki
Returns:
a SearchResults instance containing the results.

getSearchResults

public SearchResults getSearchResults(java.lang.String query,
                                      java.lang.String[] sortField,
                                      java.lang.String languages)
Searches the configured Indexes using the specified lucene query for documents in the given languages.

With virtual wikis enabled in your xwiki installation this will deliver results from all virtuall wikis. For searching in a subset of your virtual wikis see #getSearchResults(String, String, String, com.xpn.xwiki.api.XWiki)

Parameters:
query - query entered by the user
languages - comma separated list of language codes to search in, may be null to search all languages. Language codes can be:
  • default for content having no specific language information
  • lower case 2-letter language codes like en, de as used by xwiki
Returns:
a SearchResults instance containing the results.

getSearchResults

public SearchResults getSearchResults(java.lang.String query,
                                      java.lang.String[] sortField,
                                      java.lang.String virtualWikiNames,
                                      java.lang.String languages)
Searches the configured Indexes using the specified lucene query for documents in the given languages belonging to one of the given virtual wikis.

Using this method only makes sense with virtual wikis enabled. Otherwise use #getSearchResults(String, String, com.xpn.xwiki.api.XWiki) instead.

Parameters:
query - query entered by the user
sortField - field to sort on
virtualWikiNames - Names of the virtual wikis to search in. May be null for global search.
languages - comma separated list of language codes to search in, may be null to search all languages. Language codes can be:
  • default for content having no specific language information
  • lower case 2-letter language codes like en, de as used by xwiki
Returns:
a SearchResults instance containing the results.


Copyright © 2004-2010 XWiki. All Rights Reserved.