Changeset 6137

Show
Ignore:
Timestamp:
06/02/07 20:49:10 (1 year ago)
Author:
tarjei
Message:

fix #32 Create a new indexer backend for solr.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.core/midcom/services/indexer.php

    r3766 r6137  
    232232            return true; 
    233233        } 
    234  
    235234        return $this->_backend->delete_all(); 
    236235    } 
     
    245244     * The query syntax is also dependant on the backend. Refer to its documentation 
    246245     * how queries should be built. 
    247      * 
    248      * Each result node is looked up in NAP/Metadata to verify its visibility. 
    249246     * 
    250247     * @param string $query The query, which must suite the backends query syntax. It is assumed to be in the site charset. 
     
    293290            } 
    294291 
     292            // this checks acls! 
    295293            if ($document->is_a('midcom')) 
    296294            { 
     
    304302                } 
    305303            } 
    306  
    307             // For all midcom doucments, check the metadata visibility state given by the source object. 
    308             // Do this only if MidCOM is configured to do so 
    309             if (   $document->is_a('midcom') 
    310                 && (   $midcom_config['show_hidden_objects'] 
    311                     || $midcom_config['show_unapproved_objects'])) 
    312             { 
    313                 $metadata =& midcom_helper_metadata::retrieve($document->source); 
    314  
    315                 if (   $metadata 
    316                     && ! $metadata->is_object_visible_onsite()) 
    317                 { 
    318                     debug_add("Skipping the document {$document->title}, the metadata of the source document {$document->source} indicate no visibility."); 
    319                     continue; 
    320                 } 
    321  
    322                 // Drop the reference again. 
    323                 unset($metadata); 
    324             } 
    325  
    326             // Check for additional security checks by the component or a custom callback 
    327             $component_loader =& $_MIDCOM->get_component_loader(); 
    328             $security = explode(':', $document->security, 2); 
    329             switch ($security[0]) 
    330             { 
    331                 case 'component': 
    332                     // Component security, get the interface base class, if it exists, and 
    333                     // execute the corresponding handler. 
    334                     debug_add('Doing additional component-level security check'); 
    335                     $interface =& $component_loader->get_interface_class($document->component); 
    336                     if (   $interface 
    337                         && $topic 
    338                         && ! $interface->check_document_permissions($document, $topic)) 
    339                     { 
    340                         debug_add('Skipping the document, the callee returned false.'); 
    341                         continue 2; 
    342                     } 
    343                     break; 
    344  
    345                 case 'function': 
    346                     // Execute a custom callback to ascertain visbility. 
    347                     debug_add("We are in function security mode, executing the callback {$security[1]}."); 
    348                     if (! $security[1]($document, $topic)) 
    349                     { 
    350                         debug_add('Skipping the document, the callee returned false.'); 
    351                         continue 2; 
    352                     } 
    353                     break; 
    354  
    355                 case 'class': 
    356                     die ('The class security callback is disabled, it is broken from the beginning.'); 
    357                     // TODO: Fix this. 
    358  
    359                     // Execute a custom callback to ascertain visbility. 
    360                     debug_add("We are in function security mode, executing the callback {$security[1]}."); 
    361                     $class = $security[1]; 
    362                     $instance =& $class->get_instance(); 
    363                     if (! $instance->check_document_permissions($document, $topic)) 
    364                     { 
    365                         debug_add('Skipping the document, the callee returned false.'); 
    366                         continue 2; 
    367                     } 
    368                     break; 
    369             } 
    370  
    371304            $result[] = $document; 
    372305        } 
  • trunk/midcom/midcom.core/midcom/services/indexer/document.php

    r3766 r6137  
    347347    { 
    348348        // This is always UTF-8 conformant. 
    349         $this->_add_field($name, 'date', strftime('%Y-%m-%dT%H:%M:%S', $timestamp), true); 
     349        $this->_add_field($name, 'date', strftime('%Y-%m-%dT%H:%M:%SZ', $timestamp), true); 
    350350    } 
    351351 
  • trunk/midcom/midcom.helper.search/config/manifest.inc

    r5819 r6137  
    1  
    21  'name' => 'midcom.helper.search', 
    3   'version' => '1.0.3beta1', 
     2  'version' => '1.0.4beta1', 
    43  'state' => 'beta', 
    54  'purecode' => false, 
     
    2322        'active' => 'no', 
    2423      ), 
     24      'tarjei' =>  
     25      array ( 
     26        'name' => 'Tarjei Huse', 
     27        'email' => 'tarjei@nu.no', 
     28        'role' => 'lead', 
     29        'active' => 'yes', 
     30      ), 
     31  
    2532    ), 
    2633    'dependencies' =>  
     
    2936      array ( 
    3037      ), 
     38      'http_request' => 
     39         array ( 
     40            'channel' => 'pear.php.net', 
     41        ), 
    3142    ), 
    3243  ), 
  • trunk/midcom/midcom.helper.search/style/advanced_form.php

    r5048 r6137  
    11<?php 
    2 //$data =& $_MIDCOM->get_custom_context_data('request_data'); 
     2$data =& $_MIDCOM->get_custom_context_data('request_data'); 
    33$prefix = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX); 
    44 
  • trunk/midcom/midcom.helper.search/style/search_form.php

    r5048 r6137  
    1 <?php 
    2 //$data =& $_MIDCOM->get_custom_context_data('request_data'); 
    3 ?> 
    41<h1><?php echo $data['topic']->extra;?></h1> 
    52 
  • trunk/midcom/midcom.helper.search/viewer.php

    r4120 r6137  
    5858            case 'advanced': 
    5959                $data['query'] = (array_key_exists('query', $_REQUEST) ? $_REQUEST['query'] : ''); 
    60                 $data['topic'] = (array_key_exists('topic', $_REQUEST) ? $_REQUEST['topic'] : ''); 
     60                //$data['topic'] = (array_key_exists('topic', $_REQUEST) ? $_REQUEST['topic'] : ''); 
    6161                $data['component'] = (array_key_exists('component', $_REQUEST) ? $_REQUEST['component'] : ''); 
    6262                $data['lastmodified'] = (array_key_exists('lastmodified', $_REQUEST) ? ((integer) $_REQUEST['lastmodified']) : 0); 
     
    105105                                if (   count(explode(' ', $data['query'])) == 1 
    106106                                    && !strstr($data['query'], '*')) 
     107                                { 
     108                                    // Single search term, append * 
     109                    if ($GLOBALS['midcom_config']['indexer_backend'] != 'solr')  
     110                    { 
     111                                        $data['query'] .= '*'; 
     112                    } 
     113                                } 
     114                                 
     115                                $result = $indexer->query($data['query']); 
     116                break; 
     117             
     118            case 'advanced': 
     119                $data['query'] = trim($_REQUEST['query']); 
     120                 
     121                                if (   count(explode(' ', $data['query'])) == 1 
     122                                    && !strstr($data['query'], '*') && $GLOBALS['midcom_config']['indexer_backend'] != 'solr' ) 
    107123                                { 
    108124                                    // Single search term, append * 
     
    110126                                } 
    111127                                 
    112                                 $result = $indexer->query($data['query']); 
    113                 break; 
    114              
    115             case 'advanced': 
    116                 $data['query'] = trim($_REQUEST['query']); 
    117                  
    118                                 if (   count(explode(' ', $data['query'])) == 1 
    119                                     && !strstr($data['query'], '*')) 
    120                                 { 
    121                                     // Single search term, append * 
    122                                     $data['query'] .= '*'; 
    123                                 } 
    124                                  
    125                                 $data['topic'] = trim($_REQUEST['topic']); 
    126                 // $data['topic2'] = trim($_REQUEST['topic2']); 
     128                                $data['request_topic'] = trim($_REQUEST['topic']); 
    127129                $data['component'] = trim($_REQUEST['component']); 
    128130                $data['lastmodified'] = (integer) trim($_REQUEST['lastmodified']); 
     
    136138                } 
    137139                 
    138                 if ($data['query'] != ''
    139                 { 
    140                     $final_query = "({$data['query']})"; 
     140                if ($data['query'] != ''
     141                { 
     142                    $final_query = ( $GLOBALS['midcom_config']['indexer_backend'] == 'solr' ) ? $data['query'] : "({$data['query']})"; 
    141143                } 
    142144                else 
     
    145147                } 
    146148                 
    147                 if ($data['topic'] != '') 
     149                if ($data['request_topic'] != '') 
    148150                { 
    149151                    if ($final_query != '') 
     
    151153                        $final_query .= ' AND '; 
    152154                    } 
    153                     $final_query .= "__TOPIC_URL:\"{$data['topic']}*\""; 
    154                 } 
    155                 /* 
    156                 *This if makes able to search more than one topics 
    157                 *You need to put in to the input value in the search form topics separated by ; 
    158                 *no spaces 
    159                 * / 
    160                 if ($data['topic2'] != '') 
    161                 { 
    162                         if ($final_query != '') 
    163                     { 
    164                         $final_query .= ' AND '; 
    165                     } 
    166                         $topic_arrays = explode(";" ,$data['topic2']); 
    167                         $final_tmp_query = ""; 
    168                          
    169                         foreach ($topic_arrays as $topic_tmp) 
    170                         { 
    171                         if ($final_tmp_query != '') 
    172                             { 
    173                             $final_tmp_query .= ' OR '; 
    174                             } 
    175                             else 
    176                             { 
    177                                     $final_tmp_query .= " ( "; 
    178                             } 
    179                         $final_tmp_query .= "__TOPIC_URL:\"{$topic_tmp}*\""; 
    180                         } 
    181                         $final_tmp_query .= " )"; 
    182                          
    183                          
    184                     $final_query .= $final_tmp_query; 
    185                 } 
    186                 */ 
    187                  
     155                    $final_query .= "__TOPIC_URL:\"{$data['request_topic']}*\""; 
     156                } 
     157                
    188158                if ($data['component'] != '') 
    189159                {