I wanted to alter the apache solr search form by adding my own custom textfields, dropdowns. I tried using the regular form alter hook but it works only for the Core search i.e custom fields appear for core search. On the Apache Solr form these form elements are not getting rendered.

Is there a way to achieve this kind of functionality ? Or any other Apache solr hook perhaps.

  • Before coding something, have you tried this module to add facets to your solr? – DeveloperWeeks Jan 19 '16 at 18:22

You need to add facetsapi module and in form alter add the custom fields. On form submit you need to use

$keys = $form_state->getValue('keys');
$custom = $form_state->getValue('user_custom_field');
$form_state->setRedirectUrl(Url::fromRoute('search_api_page.en' . '.' . $form_state->getValue('search_api_page'), array('keys' => $keys), array('query' => array('facet_key' => $custom))));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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