[TYPO3-Solr] Reindex SOLR records via custom extension

Jigal van Hemert jigal.van.hemert at typo3.org
Sat Feb 6 13:14:17 CET 2016


Hi,

On 04/02/2016 10:28, Michal Cygankiewicz wrote:
> I have SOLR configured so it is indexing some custom TYPO3 records.
>
> Those records are synchronized (modified, deleted, created) via
> Scheduler task based on 3rd party data source. What is the best way to
> provoke SOLR to reindex only choosen items from custom TYPO3 extension?
> I don't want to reindex all records - just those which are beeing
> changed during synchronization.

Instead of directly writing in the database it's better to use the 
DataHandler class to insert/update/remove records. EXT:solr uses a hook 
in this class to monitor changes and will automatically mark new/changed 
records for re-indexing. Removed records are also automatically removed 
from the solr index.

The scheduler task is running under the user _cli_scheduler, so don't 
forget to give that user read/write rights to the tables and make sure 
it may write to all exclude fields as necessary.

Once you've used DataHandler you'll soon appreciate everything it does 
for you:
- fields like timestamp, crdate, and so on are automatically handled
- for relations with other tables via MM-tables you only need to supply 
a list of IDs; the relations are automatically updated according to TCA 
settings
- system references are updated
- caches are cleared (if configured)
- history for the record is updated
- hooks (such as the solr record monitor) are executed

If you still want to do it yourself you can mark the record for 
re-indexing [1] (uses old class names, but that isn't too hard to fix) 
and you can have a look in the record monitor for code to remove item 
from the solr index if you delete/hide one of your records.

[1] https://forge.typo3.org/projects/extension-solr/wiki/Extension_API

-- 
Jigal van Hemert
TYPO3 CMS Active Contributor

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-project-solr mailing list