Beispiel #1
0
 /**
  * Prepares an article for indexing.
  */
 protected function getDocument(&$record)
 {
     $doc = new JSolrApacheSolrDocument();
     $created = JFactory::getDate($record->created);
     $modified = JFactory::getDate($record->modified);
     if ($created > $modified) {
         $modified = $created;
     }
     $lang = $this->getLanguage($record, false);
     $doc->addField('created', $created->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField('modified', $modified->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField("title", $record->title);
     $doc->addField("title_{$lang}", $record->title);
     $doc->addField("access", $record->access);
     $doc->addField("title_ac", $record->title);
     // for auto complete
     $record->summary = JSolrHelper::prepareContent($record->summary, $record->params);
     $record->body = JSolrHelper::prepareContent($record->body, $record->params);
     $doc->addField("body_{$lang}", strip_tags($record->summary));
     $doc->addField("body_{$lang}", strip_tags($record->body));
     foreach (explode(',', $record->metakey) as $metakey) {
         $doc->addField("metakeywords_{$lang}", trim($metakey));
     }
     $doc->addField("metadescription_{$lang}", $record->metadesc);
     $doc->addField("author", $record->author);
     $doc->addField("author_fc", $this->getFacet($record->author));
     // for faceting
     $doc->addField("author_ac", $record->author);
     // for auto complete
     foreach (JSolrHelper::getTags($record, array("<h1>")) as $item) {
         $doc->addField("tags_h1_{$lang}", $item);
     }
     foreach (JSolrHelper::getTags($record, array("<h2>", "<h3>")) as $item) {
         $doc->addField("tags_h2_h3_{$lang}", $item);
     }
     foreach (JSolrHelper::getTags($record, array("<h4>", "<h5>", "<h6>")) as $item) {
         $doc->addField("tags_h4_h5_h6_{$lang}", $item);
     }
     $doc->addField("hits_i", (int) $record->hits);
     if ($record->catid) {
         $doc->addField("parent_id", $record->catid);
         $doc->addField("category_{$lang}", $record->category);
         $doc->addField("category_fc", $this->getFacet($record->category));
         // for faceting
     }
     return $doc;
 }
Beispiel #2
0
 /**
  * Prepares a listing for indexing.
  */
 protected function getDocument(&$record)
 {
     $doc = new JSolrApacheSolrDocument();
     $created = JFactory::getDate($record->created);
     $modified = JFactory::getDate($record->modified);
     $lang = $this->getLanguage($record, false);
     $created = JFactory::getDate($record->created);
     $modified = JFactory::getDate($record->modified);
     $publishUp = JFactory::getDate($record->publish_up);
     $publishDown = JFactory::getDate($record->publish_down);
     if ($created > $modified) {
         $modified = $created;
     }
     $lang = $this->getLanguage($record, false);
     $doc->addField('created', $created->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField('modified', $modified->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField('publish_up_dt', $publishUp->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField('publish_down_dt', $publishDown->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField("title", $record->title);
     $doc->addField("title_{$lang}", $record->title);
     $doc->addField("access", $record->access);
     $doc->addField("title_ac", $record->title);
     // for auto complete
     $doc->addField("title_sort", $record->title);
     $record->summary = JSolrHelper::prepareContent($record->summary, $record->params);
     $record->body = JSolrHelper::prepareContent($record->body, $record->params);
     $doc->addField("body_{$lang}", strip_tags($record->summary));
     $doc->addField("body_{$lang}", strip_tags($record->body));
     foreach (explode(',', $record->metakey) as $metakey) {
         $doc->addField("metakeywords_{$lang}", trim($metakey));
     }
     $doc->addField("metadescription_{$lang}", $record->metadesc);
     $doc->addField("author", $record->author);
     $doc->addField("author_fc", $record->author);
     // for faceting
     $doc->addField("author_ac", $record->author);
     // for auto complete
     foreach (JSolrHelper::getTags($record, array("<h1>")) as $item) {
         $doc->addField("tags_h1_{$lang}", $item);
     }
     foreach (JSolrHelper::getTags($record, array("<h2>", "<h3>")) as $item) {
         $doc->addField("tags_h2_h3_{$lang}", $item);
     }
     foreach (JSolrHelper::getTags($record, array("<h4>", "<h5>", "<h6>")) as $item) {
         $doc->addField("tags_h4_h5_h6_{$lang}", $item);
     }
     $doc->addField("hits_i", (int) $record->hits);
     if ($record->catid) {
         $doc->addField("parent_id", $record->catid);
         $doc->addField("category_{$lang}", $record->category);
         $doc->addField("category_fc", $record->category);
         // for faceting
     }
     // index image data (if available)
     if ($record->media_type == 'photo' && $record->main_media == 1) {
         $doc->addField("media_id_i", (int) $record->media_id);
         $doc->addField("media_relative_path_s", $record->rel_path);
         $doc->addField("media_filename_s", $record->filename);
         $doc->addField("media_fileextension_s", $record->file_extension);
         $doc->addField("media_filesize_i", (int) $record->filesize);
         $doc->addField("media_info_s", $record->media_info);
         $doc->addField("media_metadata_s", $record->media_metadata);
         $doc->addField("media_published_i", (int) $record->media_published);
         $doc->addField("media_extension_s", $record->media_extension);
     }
     $doc->addField("video_count_i", (int) $record->video_count);
     $doc->addField("photo_count_i", (int) $record->photo_count);
     $doc->addField("audio_count_i", (int) $record->audio_count);
     $doc->addField("attachment_count_i", (int) $record->attachment_count);
     if (isset($record->user_rating)) {
         $doc->addField("user_rating_tf", $record->user_rating);
     }
     if (isset($record->user_rating_count)) {
         $doc->addField("user_rating_count_i", (int) $record->user_rating_count);
     }
     if (isset($record->user_criteria_rating)) {
         $doc->addField("user_criteria_rating_tf", $record->user_criteria_rating);
     }
     if (isset($record->user_criteria_rating_count)) {
         $doc->addField("user_criteria_rating_count_i", (int) $record->user_criteria_rating_count);
     }
     if (isset($record->review_count)) {
         $doc->addField("review_count_i", (int) $record->review_count);
     }
     if (isset($record->editor_rating)) {
         $doc->addField("editor_rating_tf", $record->editor_rating);
     }
     if (isset($record->editor_rating_count)) {
         $doc->addField("editor_rating_count_i", (int) $record->editor_rating_count);
     }
     if (isset($record->editor_criteria_rating)) {
         $doc->addField("editor_criteria_rating_tf", $record->editor_criteria_rating);
     }
     if (isset($record->editor_criteria_rating_count)) {
         $doc->addField("editor_criteria_rating_count_s", $record->editor_criteria_rating_count);
     }
     if (isset($record->editor_review_count)) {
         $doc->addField("editor_review_count_s", $record->editor_review_count);
     }
     if (isset($record->favorites)) {
         $doc->addField("favorites_i", (int) $record->favorites);
     }
     // Obtain the configured fields to index.
     if (array_search('jsolr_all', $this->params->def('index_fields')) === false) {
         $indexes = $this->params->def('index_fields');
     } else {
         $indexes = $this->_getJRFields();
     }
     foreach ($indexes as $index) {
         $key = JString::strtolower(JStringNormalise::toVariable($index));
         $doc->addField($key . '_txt', $record->{$index});
         // for searching.
         switch ($this->_getJRField($index)->type) {
             case 'checkboxes':
             case 'selectmultiple':
             case 'radiobuttons':
                 foreach (explode('*', $record->{$index}) as $value) {
                     if (!empty($value)) {
                         $doc->addField($key . '_sm', $value);
                     }
                 }
                 break;
             case 'integer':
                 $doc->addField($key . '_i', (int) $record->{$index});
                 break;
             default:
                 $doc->addField($key . '_s', $record->{$index});
                 // for faceting
                 break;
         }
     }
     // Obtain the configured fields to index.
     if (array_search('jsolr_all', $this->params->def('facet_fields')) === false) {
         $facets = $this->params->def('facet_fields');
     } else {
         $facets = $this->_getJRFields();
     }
     // Obtain the configured fields to facet.
     foreach ($facets as $facet) {
         $key = JString::strtolower(JStringNormalise::toVariable($facet));
         switch ($this->_getJRField($facet)->type) {
             case 'checkboxes':
             case 'selectmultiple':
             case 'radiobuttons':
                 foreach (explode('*', rtrim(ltrim($record->{$facet}, '*'), '*')) as $value) {
                     if (!empty($value)) {
                         $doc->addField($key . '_fc', $value);
                     }
                 }
                 break;
             default:
                 if (!empty($record->{$facet})) {
                     $doc->addField($key . '_fc', $record->{$facet});
                     // for faceting
                 }
                 break;
         }
     }
     return $doc;
 }
Beispiel #3
0
 /**
  * Prepares an article for indexing.
  */
 protected function getDocument(&$record)
 {
     $doc = new JSolrApacheSolrDocument();
     $created = JFactory::getDate($record->created);
     $modified = JFactory::getDate($record->modified);
     $lang = $this->getLanguage($record, false);
     $doc->addField('created', $created->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField('modified', $modified->format('Y-m-d\\TH:i:s\\Z', false));
     $doc->addField("title", $record->title);
     $doc->addField("title_{$lang}", $record->title);
     $doc->addField("link_{$lang}", $record->link);
     $doc->addField("access", $record->access);
     foreach (explode(',', $record->metakey) as $metakey) {
         $doc->addField("metakeywords_{$lang}", trim($metakey));
     }
     $doc->addField("metadescription_{$lang}", $record->metadesc);
     $doc->addField("author", $record->author);
     if ($record->catid) {
         $doc->addField("parent_id", $record->catid);
         $doc->addField("category_{$lang}", $record->category);
         $doc->addField("category_fc", $record->category);
         // facet
     }
     return $doc;
 }