? SolrPhpClient
? apachesolr62.kpf
? mlt.patch
Index: apachesolr.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.admin.inc,v
retrieving revision 1.1.2.28.2.17
diff -u -p -r1.1.2.28.2.17 apachesolr.admin.inc
--- apachesolr.admin.inc	18 Dec 2009 09:58:34 -0000	1.1.2.28.2.17
+++ apachesolr.admin.inc	18 Dec 2009 10:53:32 -0000
@@ -596,6 +596,45 @@ function apachesolr_mlt_block_form($delt
     '#options' => drupal_map_assoc(array(3, 5, 7, 10, 12, 15, 20, 25, 30, 35, 40)),
     '#default_value' => $block['mlt_maxqt'],
   );
+  
+  $form['restrictions'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Filters'),
+    '#weight' => '1',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+
+  $type_options = array();
+  foreach (node_get_types('types') as $key => $type) {
+    $type_options[$key] = $type->name;
+  }
+
+  $form['restrictions']['mlt_type_filters'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Content Types'),
+    '#default_value' => is_array($block['mlt_type_filters']) ? $block['mlt_type_filters'] : array_keys($type_options),
+    '#options' => $type_options,
+    '#description' => t('Select the content types that similarity suggestions should be restricted to. Multiple types are joined with an OR query, so selecting more types results in more recommendations.'),
+    '#weight' => '-2',
+  );
+
+  $form['restrictions']['mlt_custom_filters'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Additional Query'),
+    '#description' => t('An additional query, in Lucene syntax, which will further filter the similarity suggestions. Ex. \'title:strategy\' will filter related content further to only those with strategy in the title. ' .
+                        'Likewise \'body:HDTV^3\' will boost the term HDTV by a factor of 3. Here are some more examples:' .
+                        '<ul>
+                            <li>language:fr</li>
+                            <li>tid:5 OR tid 7</li>
+                            <li>created:[2009-05-01T23:59:59Z TO 2009-07-28T12:30:00Z]</li>
+                            <li>-uid:0 AND -uid:1</li>
+                        </ul>'),
+    '#required' => FALSE,
+    '#default_value' => $block['mlt_custom_filters'],
+    '#weight' => '-1',
+  );
+
 
   return $form;
 }
@@ -616,6 +655,8 @@ function apachesolr_mlt_block_defaults($
     'mlt_minwl' => '3',
     'mlt_maxwl' => '15',
     'mlt_maxqt' => '20',
+    'mlt_type_filters' => array_keys(node_get_types('types')),
+    'mlt_custom_filters' => '',
   );
 }
 
@@ -663,6 +704,8 @@ function apachesolr_mlt_save_block($bloc
   $blocks[$delta] = array_intersect_key($block_settings, $defaults) + $defaults;
   // Eliminate non-selected fields.
   $blocks[$delta]['mlt_fl'] = array_filter($blocks[$delta]['mlt_fl']);
+  $blocks[$delta]['mlt_type_filters'] = array_filter($blocks[$delta]['mlt_type_filters']);
+  $blocks[$delta]['mlt_custom_filters'] = trim($blocks[$delta]['mlt_custom_filters']);
   variable_set('apachesolr_mlt_blocks', $blocks);
 }
 
Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.155.2.47
diff -u -p -r1.1.2.12.2.155.2.47 apachesolr.module
--- apachesolr.module	18 Dec 2009 09:58:34 -0000	1.1.2.12.2.155.2.47
+++ apachesolr.module	18 Dec 2009 10:53:32 -0000
@@ -1692,6 +1692,18 @@ function apachesolr_mlt_suggestions($set
       }
     }
     $query = apachesolr_drupal_query('id:' . $id);
+    
+    $type_filters = array();
+    if (is_array($settings['mlt_type_filters'])) {
+      foreach ($settings['mlt_type_filters'] as $type_filter) {
+        $type_filters[] = "type:{$type_filter}";
+      }
+      $params['fq']['mlt'][] = '(' . implode(' OR ', $type_filters) . ') ';
+    }
+
+    if ($custom_filters = $settings['mlt_custom_filters']) {
+      $params['fq']['mlt'][] = $custom_filters;
+    }
 
     // This hook allows modules to modify the query and params objects.
     apachesolr_modify_query($query, $params, 'apachesolr_mlt');
