IFullTextSearchProvider¶
-
interface
OCP\FullTextSearch\
IFullTextSearchProvider
¶ - Interface IFullTextSearchProviderThis interface must be use when creating a Content Provider for FullTextSearch.A Content Provider is an extension to the FullTextSearch that will extract andprovide content to the FullTextSearch.There is no limit to the number of Content Provider that can be integrated toFullTextSearch. Each Content Provider corresponding to a type of contentavailable in Nextcloud (files, bookmarks, notes, deck cards, mails, ...)Content is split in document identified by an ID and the ID of the ContentProvider. The content is indexed by a Search Platform that will returns adocumentId as a result on a search request.To oversimplify the mechanism:- When indexing, FullTextSearch will ask for documents to every Content Provider.- On search, results from the Search Platform, identified by documentId, willbe improved by each relative Content Provider.The Content Provider is a PHP class that implement this interface and is definedin appinfo/info.xml of the app that contains that class:<fulltextsearch><provider>OCA\YourApp\YourContentProvider</provider></fulltextsearch>Multiple Content Provider can be defined in a single app.
Source: lib/public/FullTextSearch/IFullTextSearchProvider.php#74
Methods¶
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
getId
()¶ - Must returns a unique Id used to identify the Content Provider.Id must contains only alphanumeric chars, with no space.
Source: lib/public/FullTextSearch/IFullTextSearchProvider.php#85 Since: 15.0.0 Returns: string
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
getName
()¶ - Must returns a descriptive name of the Content Provider.This is used in multiple places, so better use a clear display name.
Source: lib/public/FullTextSearch/IFullTextSearchProvider.php#96 Since: 15.0.0 Returns: string
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
getConfiguration
()¶ - Should returns the current configuration of the Content Provider.This is used to display the configuration when using the./occ fulltextsearch:check command line.
Source: lib/public/FullTextSearch/IFullTextSearchProvider.php#108 Since: 15.0.0 Returns: array
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
getSearchTemplate
()¶ - Must returns a ISearchTemplate that contains displayable items andavailable options to users when searching.
Source: lib/public/FullTextSearch/IFullTextSearchProvider.php#121 See: \OCP\FullTextSearch\Model\ISearchTemplate
Since: 15.0.0 Returns: \OCP\FullTextSearch\Model\ISearchTemplate
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
loadProvider
()¶ - Called when FullTextSearch is loading your Content Provider.
Source: lib/public/FullTextSearch/IFullTextSearchProvider.php#129 Since: 15.0.0
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
setRunner
($runner)¶ - Set the wrapper of the currently executed process.Because the index process can be long and heavy, and because errors canbe encountered during the process, the IRunner is a wrapper that allow theContent Provider to communicate with the process initiated byFullTextSearch.The IRunner is coming with some methods so the Content Provider canreturns important information and errors to be displayed to the admin.
Source: Parameters: - $runner (
OCP\FullTextSearch\Model\IRunner
)
Since: 15.0.0
- $runner (
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
setIndexOptions
($options)¶ - This method is called when the administrator specify options when runningthe ./occ fulltextsearch:index or ./occ fulltextsearch:live
Source: Parameters: - $options (
OCP\FullTextSearch\Model\IIndexOptions
)
Since: 15.0.0
- $options (
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
generateChunks
($userId)¶ - Allow the provider to generate a list of chunk to split a huge list ofindexable documentsDuring the indexing the generateIndexableDocuments method will be calledfor each entry of the returned array.If the returned array is empty, the generateIndexableDocuments() will becalled only once (per user).
Source: Parameters: - $userId (string)
Since: 16.0.0
Returns: string[]
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
generateIndexableDocuments
($userId, $chunk)¶ - Returns all indexable document for a user as an array of IIndexDocument.There is no need to fill each IIndexDocument with content; at this point,only fill the object with the minimum information to not waste memory whilestill being able to identify the document it is referring to.FullTextSearch will call 2 other methods of this interface for eachIIndexDocument of the array, prior to their indexing:- first, to compare the date of the last index,- then, to fill each IIndexDocument with complete data
Source: Parameters: - $userId (string)
- $chunk (string)
See: Since: 15.0.0 -> 16.0.0: the parameter “$chunk” was added
Returns:
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
isDocumentUpToDate
($document)¶ - Called to verify that the document is not already indexed and that theold index is not up-to-date, using the IIndex fromIIndexDocument->getIndex()Returning true will not queue the current IIndexDocument to any furtheroperation and will continue on the next element from the list returned bygenerateIndexableDocuments().
Source: Parameters: - $document (
OCP\FullTextSearch\Model\IIndexDocument
)
Since: 15.0.0
Returns: bool
- $document (
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
fillIndexDocument
($document)¶ - Must fill IIndexDocument with all information relative to the document,before its indexing by the Search Platform.Method is called for each element returned previously bygenerateIndexableDocuments().
Source: Parameters: - $document (
OCP\FullTextSearch\Model\IIndexDocument
)
See: Since: 15.0.0
- $document (
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
updateDocument
($index)¶ - The Search Provider must create and return an IIndexDocumentbased on the IIndex and its status. The IIndexDocument must contains allinformation as it will be send for indexing.Method is called during a cron or a ./occ fulltextsearch:live after anew document is created, or an old document is set as modified.
Source: Parameters: - $index (
OCP\FullTextSearch\Model\IIndex
)
Since: 15.0.0
Returns: - $index (
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
onInitializingIndex
($platform)¶ - Called when an index is initiated by the administrator.This is should only be used in case of a specific mapping is needed.(ie. _almost_ never)
Source: Parameters: - $platform (
OCP\FullTextSearch\IFullTextSearchPlatform
)
Since: 15.0.0
- $platform (
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
onResettingIndex
($platform)¶ - Called when administrator is resetting the index.This is should only be used in case of a specific mapping has beencreated.
Source: Parameters: - $platform (
OCP\FullTextSearch\IFullTextSearchPlatform
)
Since: 15.0.0
- $platform (
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
improveSearchRequest
($searchRequest)¶ - Method is called when a search request is initiated by a user, prior tobe sent to the Search Platform.Your Content Provider can interact with the ISearchRequest to apply thesearch options and make the search more precise.
Source: Parameters: - $searchRequest (
OCP\FullTextSearch\Model\ISearchRequest
)
See: Since: 15.0.0
- $searchRequest (
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
improveSearchResult
($searchResult)¶ - Method is called after results of a search are returned by theSearch Platform.Your Content Provider can detail each entry with local data to improvethe display of the search result.
Source: Parameters: - $searchResult (
OCP\FullTextSearch\Model\ISearchResult
)
See: Since: 15.0.0
- $searchResult (
-
public
OCP\FullTextSearch\IFullTextSearchProvider::
unloadProvider
()¶ - not used yet.
Source: lib/public/FullTextSearch/IFullTextSearchProvider.php#316 Since: 15.0.0