You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by John Bickerstaff <jo...@johnbickerstaff.com> on 2016/03/31 18:26:37 UTC
How to reference search term(s) in searchHandler
I believe I want to set up a search handler with a function query to avoid
needing to code it.
The function query does some weighting by checking the "title" field for
whatever the user entered as their search term (named myCurrentSearchTerm
below)
To test this out in the Admin UI, I have the following under the edismax
"pop-out"
bf: product(query($titleQuery),10000)
the "titleQuery" was set up in the Raw Query Parameters field thus:
titleQuery=title:(myCurrentSearchTerm)
I imagine there must be a way to duplicate this in a searchHandler inside
the solrconfig.xml file, but I'm not sure how the syntax would work. In
particular, what is the magic incantation to reference what is coming in as
the user's search term?
If, for example, my URL contained [q=gastrointestinal] how can I reference
that inside the searchHandler XML?
I have something like this in mind - can anyone on the list tell me if this
is wrong and if so, what would be right?
I'm only guessing that *$q* might represent the incoming search terms... I
can't find any examples online to guide me.
<requestHandler name="/foo" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
will be overridden by parameters in the request
-->
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">20</int>
<!-- Query settings -->
<str name="defType">edismax</str>
<str name="df">text</str>
*<str name="bf"> product(query(title:($q)),10000)</str>*
</lst>
</requestHandler>
Is it even possible to directly reference the search terms inside a
searchHandler like this?
Do I have the wrong idea here and should be trying a different approach?
Thanks...