$_backend
$_backend : \midcom_services_indexer_backend
The backend indexer implementation
This class is the main access point into the MidCOM Indexer subsystem.
It allows you to maintain and query the document index.
Do not instantiate this class directly. Instead use the get_service method on midcom_application using the service name 'indexer' to obtain a running instance.
$_backend : \midcom_services_indexer_backend
The backend indexer implementation
__construct(\midcom_services_indexer_backend $backend = null)
Initialization
The constructor will initialize the indexer backend using the MidCOM configuration by default. If you need a different indexer backend, you can always explicitly instantiate a backend and pass it to the constructor. In that case you have to load the corresponding PHP file manually.
\midcom_services_indexer_backend | $backend | An explicit indexer to initialize with. |
handle_delete(\midcom\events\dbaevent $event)
\midcom\events\dbaevent | $event |
index(mixed $documents) : boolean
Adds a document to the index.
A finished document object must be passed to this object. If the index already contains a record with the same Resource Identifier, the record is replaced.
Support of batch-indexing using an Array of documents instead of a single document is possible (and strongly advised for performance reasons).
mixed | $documents | One or more documents to be indexed, so this is either a midcom_services_indexer_document or an Array of these objects. |
Indicating success.
delete(array $RIs) : boolean
Removes the document(s) with the given resource identifier(s) from the index.
Using GUIDs instead of RIs will delete all language versions
array | $RIs | The resource identifier(s) of the document(s) that should be deleted. |
Indicating success.
query(string $query, \midcom_services_indexer_filter $filter = null, array $options = array()) : array<mixed,\midcom_services_indexer_document>
Query the index and, if set, restrict the query by a given filter.
The filter argument is optional and may be a subclass of indexer_filter. The backend determines what filters are supported and how they are treated.
The query syntax is also dependent on the backend. Refer to its documentation how queries should be built.
string | $query | The query, which must suit the backends query syntax. It is assumed to be in the site charset. |
\midcom_services_indexer_filter | $filter | An optional filter used to restrict the query. |
array | $options | Options that are passed straight to the backend |
An array of documents matching the query, or false on a failure.
new_document(object $object) : \midcom_services_indexer_document
Try to instantiate the most specific document class for the object given in the parameter.
This class will not return empty document base class instances if nothing specific can be found. If you are in this situation, you need to instantiate an appropriate document manually and populate it.
The checking sequence is like this right now:
This factory method will work even if the indexer is disabled. You can check this with the enabled() method of this class.
object | $object | The object for which a document instance is required |
A valid document class as specific as possible. Returns false on error or if no specific class match could be found.