Morph query parameters for the modern UI
Managed by | Updated .
Classic UI had a feature known as morph query parameters.
This is not implemented in the Modern UI that ships with v11 (and possibly not v12)
Introduction
Morph query parameters enable the user to choose the type of operation that is applied to the query via a select list. For example, the user can enter the query Opera House and then choose to have the query processed as a phrase, proximity, boolean AND, Boolean OR, a negation or as a metadata search.
See: http://docs.funnelback.com/11.4/morph_query_parameters.html
How to add this to modern UI
Versions 13+
This functionality comes packaged within the simple.ftl template.
<!-- Snippet from simple.ftl advanced search form -->
<fieldset>
<legend>Contents</legend>
<div class="form-group">
<label class="col-md-4 control-label" for="query-advanced">Any</label>
<div class="col-md-8">
<input type="text" id="query-advanced" name="query" value="${question.inputParameterMap["query"]!}" class="form-control input-sm" placeholder="e.g. juliet where thou love">
</div>
</div>
<div class="form-group">
<label for="query_and" class="col-md-4 control-label">All</label>
<div class="col-md-8">
<input type="text" id="query_and" name="query_and" value="${question.inputParameterMap["query_and"]!}" class="form-control input-sm" placeholder="e.g. juliet where thou love">
</div>
</div>
<div class="form-group">
<label for="query_phrase" class="col-md-4 control-label">Phrase</label>
<div class="col-md-8">
<input type="text" id="query_phrase" name="query_phrase" value="${question.inputParameterMap["query_phrase"]!}" class="form-control input-sm" placeholder="e.g. to be or not to be">
</div>
</div>
<div class="form-group">
<label for="query_not" class="col-md-4 control-label">Not</label>
<div class="col-md-8">
<input type="text" id="query_not" name="query_not" value="${question.inputParameterMap["query_not"]!}" class="form-control input-sm" placeholder="e.g. brutus othello">
</div>
</div>
</fieldset>
Versions 11 and 12
- Create a hook_pre_process.groovy script for your collection containing the following code:
// Implement morph query parameters functionality
// NOTE: This script assumes that for every morph_target_<param> value set there will be a corresponding morph_<param> value.
def q=transaction.question;
q.inputParameterMap.each {
// Check to see if there is a morph_target_* parameter
def k = it.key =~ /(?i)^morph_target_(.*)/;
if (k.find()) {
// Get the value of the corresponding morph_* parameter
def param = "morph_"+k[0][1];
// We need to add the morphed parameter to the input parameter map as well as the raw input parameters
// maps in the data model
q.inputParameterMap[(q.inputParameterMap[(param)])] = it.value;
q.rawInputParameters[(q.inputParameterMap[(param)])] = [it.value] as String[];
// If an extra results query is being run the query and originalQuery values also need to be set as
// these (along with collection) are special values that are set before any hook script is run.
q.query = it.value;
q.originalQuery = it.value;
}
}
Spelling suggestions will not be applied back with the standard s.CheckSpelling macro. You can use a modified version of this to return the corrected query to morph_query_target is:
<#---
Displays spelling suggestions.
PL: Patched to return correct spelling suggestion links (with morph_query_target containing the correct query term).
-->
<#macro CheckSpelling>
<#if question?exists
&& question.collection?exists
&& question.collection.configuration.value("spelling_enabled")?exists
&& is_enabled(question.collection.configuration.value("spelling_enabled"))
&& response?exists
&& response.resultPacket?exists
&& response.resultPacket.spell?exists>
Did you mean: <a href="${question.collection.configuration.value("ui.modern.search_link")}?${changeParam(QueryString, "morph_target_query", response.resultPacket.spell.text?url)?html}">
<span class="funnelback-highlight">${response.resultPacket.spell.text}</span>
</a>
</#if>
</#macro>
- Replace diacritic (accented) characters
- Accessing data model variables that start with a single lower case letter
- Adding numeric metadata constraints via a hook script
- Modifying geo-spatial parameters in the data model (origin, maxdist)
- Storing custom data within the data model
- Writing hook script code for specific search types