Share » Learn » eZ Publish » Advanced development with eZ Find -...

Advanced development with eZ Find - part 2 : Indexing additional fields in Solr

Tuesday 15 June 2010 5:20:10 am

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Step 2 : Indexing year and year /month in Solr

eZ Find settings ( ezfind.ini, to be overridden in the ezfind.ini.append.php file of your extension ) allow for delegating the indexing process of an eZ Publish datatype to a given PHP class :

[SolrFieldMapSettings]
CustomMap[ezdate]=ezfSolrDocumentFieldDate

Our PHP class, randomly named , ezfSolrDocumentFieldDate inherits from the ezfSolrDocumentFieldBase class, must be added to the /extension/myextension/classes folder and must inherit the following skeleton :

<?php
class ezfSolrDocumentFieldDate extends ezfSolrDocumentFieldBase
{
   public static function getFieldName( eZContentClassAttribute $classAttribute, $subAttribute = null, $context = 'search' )
   {
     // return the fieldname like : attr_mydate_d
   }
 
   public function getData()
   {
     // return the array keys (fieldname => value), like : array('attr_mydate_dt' => '2010-04-30T00:00:00Z')
   }
}
?>
 
36 542 Users on board!

Tutorial menu

Printable

Printer Friendly version of the full article on one page with plain styles

Author(s)