Deleting an object via the API and delayed indexing

Author Message

Jim Thaxton

Wednesday 09 December 2009 11:11:59 am

Our site is setup with delayed indexing that is updated after an import runs each night. We have started to implement a feature to delete inactive objects throughout the day. The delete script runs the ->purge() and ->expireAllCache() methods on the object.

I assume this does not remove the object from the Solr search index. Would we need to run updatesearchindexsolr.php as a cron job after deletes to remove these objects? Is there an API call we can make to have the object removed from the Solr index on delete? The eZ Find extension classes do not have any delete methods as far as I can tell.

Web Developer
Coupon Cabin
Chicago, IL

Paul Borgermans

Saturday 12 December 2009 4:59:00 am

Yes, there is an API in eZ Find (or any search plugin):

Before you actually remove the objects from eZ Publish, use something like this:

$searchEngine = new eZSolr();
....
//loop over objets to delete
$searchEngine->removeObject( $contentObject, false );

And call a commit at the end:

$searchEngine->commit();

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Bertrand Dunogier

Saturday 12 December 2009 6:20:12 am

Running eZContentObject::expireAllCache() is unnecessary, and actually a bit dangerous ! It completely expires all content-cache and cache-blocks... I don't feel like it is what you need.

What you could do instead is use eZContentObjectTreeNode::removeSubtrees() with the $moveToTrash parameter set to false:

eZContentObjectTreNode::removeSubtrees( $nodeIDArray, $moveToTrash = false, $infoOnly = true );

It will take care of everything for you, including clearing appropriate caches and removing the object from the search engine index.

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:09:34
Script start
Timing: Jan 18 2025 02:09:34
Module start 'layout'
Timing: Jan 18 2025 02:09:34
Module start 'content'
Timing: Jan 18 2025 02:09:35
Module end 'content'
Timing: Jan 18 2025 02:09:35
Script end

Main resources:

Total runtime0.7979 sec
Peak memory usage4,096.0000 KB
Database Queries61

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 589.6172152.6563
Module start 'layout' 0.00590.0045 742.273439.5078
Module start 'content' 0.01040.7863 781.7813582.7031
Module end 'content' 0.79680.0011 1,364.484412.1016
Script end 0.7979  1,376.5859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4384160.0002
Check MTime0.00130.1644160.0001
Mysql Total
Database connection0.00080.099110.0008
Mysqli_queries0.749093.8679610.0123
Looping result0.00060.0779590.0000
Template Total0.758295.020.3791
Template load0.00210.266820.0011
Template processing0.756094.748820.3780
Template load and register function0.00020.023710.0002
states
state_id_array0.00110.133310.0011
state_identifier_array0.00150.188620.0008
Override
Cache load0.00180.2291180.0001
Sytem overhead
Fetch class attribute can translate value0.00060.070130.0002
Fetch class attribute name0.00120.151950.0002
XML
Image XML parsing0.00120.151030.0004
class_abstraction
Instantiating content class attribute0.00000.001450.0000
General
dbfile0.00090.1161230.0000
String conversion0.00000.001440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs