1

I have a drupal 7 installation with apache solr search: But I need to use a custom search like this:

2 TextBox fields with:
What -> Any word of the apache index.
AND
Where -> A term reference in the content type.

1 Answer 1

0

After looking for several forums and apache solr help, I made it like this...

Notes:

1 $form_state['values']['keys'] - The search text

2 $form_state['values']['localidade'] - The taxonomy term search value

function MYMODULE_search_block_form_submit($form, &$form_state) {

// Check if localidade is empty
    if (empty($form_state['values']['localidade'])) {
    // localidade empty
        drupal_goto('pesquisa/' . $form_state['values']['keys']);
    } else {
    // with localidade
    // check what is the tid of my term localidade
        $t1 = $form_state['values']['localidade'];
        $t2 = taxonomy_get_term_by_name($t1, "localidade");
        $t3 = array_shift($t2);
    // term no found
        if (empty($t3->tid)) {
            drupal_set_message('Não reconheçemos a localidade ' . $form_state['values']['localidade'] . ', por favor coloque uma localidade sugerida.');
            drupal_goto('pesquisa/');
        } else {
    // build search parameter with the term tid
            $t11 = 'pesquisa/' . $form_state['values']['keys'];
            $options['query']['search_param'] = 'f[0]=bundle:empresa&f[1]=im_field_localidade:' . $t3->tid;
            drupal_goto($t11, $options);
        }

 }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.