Hi,

I created the attached view before installing this project (see attached pic) and was able to have drop down fields to choose certain data for searching, this would then display the results on a new page.

I want to be able to do the same using Apache Solr Views but when the results are displayed on a new page i want facets as well to appear to be able to drill down the search results?

When i create the view now i can select the fields i want but i cannot get the drop down option and also cannot see about adding facets? Can anyone talk me through how to do this please?

CommentFileSizeAuthor
dropdowns.jpg41.88 KBefc84

Comments

ygerasimov’s picture

Status: Active » Fixed

Now you can create exposed filters out of fields of Solr index. But they are simple textfields so using little custom code you can alter that form and change type of the input elements to selecboxes.

You can also enable facets and they work now with a view.

Closing this issue for now. Should you have any further questions please let me know.

becw’s picture

Now you can create exposed filters out of fields of Solr index. But they are simple textfields so using little custom code you can alter that form and change type of the input elements to selecboxes.

Yes, you should be able to use a hook_form_alter() to change a textfield element to a select element and give it some hard-coded values. However, Apache Solr Views does not currently support providing a select element with values that come directly from the Solr core.

As ygerasimov says, FacetAPI facets should work as expected with Apache Solr Views; you just have to configure them outside of Views (enable facets in the Apache Solr configuration section, and then place the facet blocks).

david.gil’s picture

Some sample code if you need help:


function bk_solr_form_views_exposed_form_alter(&$form, &$form_state) {
  //dsm($form);
  if ($form['#id'] == 'views-exposed-form-buscar-page') {
    drupal_add_js(drupal_get_path('module', 'bk_solr') . '/js/ajax_view.js');

    $form['bundle']['#type'] = 'select';
    $form['bundle']['#default_value'] = 'obra';
    $form['bundle']['#options'] = array(
        'obra' => t('Colección'),
        'actividad' => t('Actividades'),
      );

    $form['clasificacion']['#type'] = 'select';
    $form['clasificacion']['#default_value'] = '';
    $form['clasificacion']['#options'] = _bk_solr_get_opciones_clasificacion();
  }
  return $form;
}

Best
David

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

acidpotato’s picture

David.gil, Thank you, thank you, thank you!