Some code from groups.drupal.org for a group specific search block. Since the integration module is owned by apachesolr right now - tag you're it.


function groupsorg_groupsearch_block_view() {
  if (!module_exists('apachesolr') || !user_access('search content')) {
    return;
  }
  if ($groupnode = og_get_group_context()) {
    $block['content'] = drupal_get_form('groupsorg_groupsearch_form', $groupnode);
    $block['subject'] = l($groupnode->title, "node/$groupnode->nid");
    return $block;
  }
}

function groupsorg_groupsearch_form(&$form_state, $groupnode) {
  if (!empty($groupnode) && !empty($groupnode->nid)) {
    $form['filters'] = array(
        '#type' => 'hidden',
        '#value' => 'im_og_gid:' . $groupnode->nid,
    );
    $form['retain-filters'] = array(
      '#type' => 'hidden',
      '#value' => 1,
    );
    
    $form['#action'] = url('search/apachesolr_search');
    $form['#method'] = 'GET';
    $form['keys'] = array(
      '#type' => 'textfield',
      '#title' => t('Enter keywords'),
      '#description' => t('Search is automatically restricted to posts in this group.'),
      '#size' => 40,
      '#maxlength' => 255,
    );
    $form['search'] = array(
      '#type' => 'submit',
      '#value' => t('Search'),
    );
    return $form;
  }
}

Comments

jpmckinney’s picture

Status: Needs review » Closed (won't fix)

I don't understand. This just looks like a good example of how to use the apachesolr API. What exactly is the proposed patch?

moshe weitzman’s picture

apachesolr_og was (is?) part of apachesolr project. this was code contributed for that module.

jpmckinney’s picture

Project: Apache Solr Search » Apache Solr Organic Groups Integration
Version: 6.x-2.x-dev »
Status: Closed (won't fix) » Active

Punting to Apache Solr Organic Groups Integration in case the maintainers want to do something with it.

ebeyrent’s picture

Assigned: Unassigned » ebeyrent

I'll take a look - thanks Moshe!

jvieille’s picture

Is that what I am looking for?
http://drupal.org/node/871332

I am very interested by this mandatory enhancement for using Apache Solr with the great OG series.

Note: Drupal core search respects OG context for returning only group relevant information and keeping its context unchanged.

jvieille’s picture

I is said that Apache Solr is used by drupal.org
groups.drupal.org presents a search block that restricts the search to the current group. If groups uses Apache solr too, that would mean that OG search is available.
In my case, the OG standard Group Search block does not make it.
How to get this apparently available feature on?

jvieille’s picture

Version: » 6.x-2.x-dev
Category: feature » support

How to get an OG group search block?
groups.drupal.org uses Solr and has it, so it should be available.
How do they do that?

Thanks

nick_vh’s picture

6.x-2.x has become unsupported. If you want to see how groups.d.o does it, I suggest you look at drupalorg module or project module? All modules used by d.o and g.d.o are available on drupal.org

nick_vh’s picture

Status: Active » Closed (won't fix)