Skip to content

Instantly share code, notes, and snippets.

@arafalov
Last active November 4, 2016 20:50
Show Gist options
  • Save arafalov/5e04884e5aefaf46678c to your computer and use it in GitHub Desktop.
Save arafalov/5e04884e5aefaf46678c to your computer and use it in GitHub Desktop.
<!--
From switch documentation: 'default' and 'case' are different things and cover different situations.
'default' covers any value being present and
'case' covers missing/empty value.
-->
<requestHandler name="/advanced" class="solr.SearchHandler">
<lst name="defaults">
<str name="rows">100</str>
</lst>
<lst name="invariants">
<str name="fq_missing">*:*</str> <!-- a replacement filter query to use, when a particular field does not match. Should have negligible effect on performance. -->
<str name="q">
{!switch case='*:*' default=$q_lastName v=$lastName}
AND {!switch case='*:*' default=$q_firstName v=$firstName}
AND {!switch case='*:*' default=$q_organizationalUnit v=$organizationalUnit}
AND {!switch case='*:*' default=$q_email v=$email}
AND {!switch case='*:*' default=$q_phoneDisplay1 v=$phoneDisplay1}
</str>
<str name="q_lastName">{!edismax qf=$param_lastName_fields v=$lastName}</str>
<str name="param_lastName_fields">LASTNAME^20 PH_LASTNAME^5 DM_LASTNAME</str>
<str name="q_firstName">{!edismax qf=$param_firstName_fields v=$firstName}</str>
<str name="param_firstName_fields">FIRSTNAME^15 PH_FIRSTNAME^5 DM_FIRSTNAME</str>
<str name="q_organizationalUnit">{!field f=ORGANIZATIONALUNIT v=$organizationalUnit}</str>
<str name="q_email">{!field f=EMAIL v=$email}</str>
<!-- even though we've been requested to search across one phone field, we'll actually all -->
<str name="q_phoneDisplay1">{!edismax qf=$param_phoneDisplay1_fields v=$phoneDisplay1}</str>
<str name="param_phoneDisplay1_fields">PHONEDISPLAY1 PHONENUMBER1 PHONENUMBERF</str>
<str name="fq">{!switch case=$fq_missing case.true=$fq_dutyStation v=$use_dutyStation}</str>
<str name="fq_dutyStation">{!term f=LOOKUP_DUTYSTATION v=$dutyStation}</str> <!-- Search against DUTYSTATION, cached as these come from a drop-down and are reused -->
</lst>
</requestHandler>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment