Forum OpenACS Development: Response to How to make an object type searchable?

Posted by Neophytos Demetriou on
No dependency is required. Actually, the triggers require that the search package is installed but the search package is part of the core, so you don't actually need to add any dependencies.
I'm trying to understand how openfts-driver, acs-service-contract, search, and the package being made searchable relate to each other.
The search package supports two contracts, namely FtsEngineDriver and FtsContentProvider.
  • FtsEngineDriver contains abstract descriptions of operations (search,index,unindex,update_index) that are common to search engines (openfts, htdig,swish,intermedia.) The search package will only make use of one implementation of the FtsEngineDriver contract. So far, only openfts-driver provides an implementation of FtsEngineDriver but efforts are under way to support other search engines as well. The choice of implementation for FtsEngineDriver leads all indexing/searching done by the search package.

  • FtsContentProvider is comprised of two operations, namely datasource and url. The former returns information about a content item (given its id) like title, content, mime, etc and it is used both while indexing and for displaying the results. The latter returns the url of a content item given its id and it is used for displaying the search results.
When inserting/updating/deleting a content item that is being "observed" (triggers have been added), the search_observer_queue table is updated with a record composed of the object_id, event (INSERT,UPDATE,DELETE), and the timestamp. With respect to the event type, we call the appropriate operation from FtsEngineDriver, for example "index". Since operations are nothing more but abstract descriptions, we are actually calling a chosen (a-priori -- in our case openfts-driver) implementation. In the case of indexing, we are choosing the function that does the indexing using FtsEngineDriver implementations. Next, we retrieve the content for an object_id using the implementation (with name the type of the object) of FtsContentProvider. Finally, the chosen indexing function is called with the content passed as an argument.