[TYPO3-Solr] additional Fields

Manfred Mirsch manfred.mirsch at tandemmedia.de
Mon Feb 20 11:23:34 CET 2012


Hi,
when adding additional fields I recognized a problem, when I tried to 
add fields with Type StringM or TextM. I entered comma seperated values 
but SOLR didn't get them as an array but as a single string.

Looking for the reason led me to the file
"class.tx_solr_additionalfieldsindexer.php".

In function "getPageDocument" the value of the given fields are stored 
but not split.

I would propose the following change:
public function getPageDocument(Apache_Solr_Document $pageDocument) {
   $substitutePageDocument = clone $pageDocument;
   $additionaFields = $this->getAdditionalFields();
   foreach ($additionaFields as $fieldName => $fieldValue) {
     if (!isset($pageDocument->{$fieldName})) {
     // making sure we only _add_ new fields
/*
  * Patch for multiple values - START
  */
       if (preg_match('/_stringM/',$fieldName) || 
preg_match('/_textM/',$fieldName)) {
         $values = array_unique(t3lib_div::trimExplode(',',$fieldValue));
         foreach ($values as $val) {
           $substitutePageDocument->addField($fieldName, $val);
         }
       } else {
         $substitutePageDocument->setField($fieldName, $fieldValue);
       }
/*
  * Patch for multiple values - ENDE
  */
     }
   }
   return $substitutePageDocument;
}


Should I post this in forge.typo3.org?

Greetings,
Manfred Mirsch


More information about the TYPO3-project-solr mailing list