Create a Solr search form on any page

Create a topic that you can include, for instance SearchForm, and write:
<div class="solrSearch">
<form name="searchform" class='solrSearchForm' action='%SCRIPTURLPATH{"view"}%/%SYSTEMWEB%/SolrSearch'>
<input type="hidden" name="filter" value="web:%BASEWEB%" />
<input type='hidden' name='web' value='%BASEWEB%' />
<div class='foswikiFormSteps'>
<div class='foswikiFormStep'>
<table class='foswikiNullTable'>
      <input type='text' class='foswikiInputField jqFocus solrSearchField' autocomplete='off' name='search' size='60' value='%URLPARAM{"search" encode="entity"}%' />
      %BUTTON{"%MAKETEXT{"Search"}%" type="submit" title="%MAKETEXT{"submit the query"}%"}%
%JQREQUIRE{"metadata, autocomplete, focus, serialscroll"}%
text="<link rel='stylesheet' href='%PUBURLPATH%/%SYSTEMWEB%/SolrPlugin/solrplugin.css' type='text/css' media='all' />"
text="<script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/SolrPlugin/solrplugin.js'></script>"

This form is configured to search in the current web. For default site-wide search, delete the hidden field filter.

-- ArthurClemens - 16 Jun 2011

SolrPlugin already comes with a search interface that can be called on any page by applying the System.SorSearchViewTemplate to it using the template url parameter. This in effect implements the facetted search solr is famous for.

See this screenshot.

To call the search interface use

<a href="%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%?template=SolrSearchView>Search</a>

To replace the standard WebSearch (as well as WebChanges and SiteChanges) interface with a SolrSearch use AutoTemplatePlugin (as a drop-in replacement for your AutoViewTemplatePlugin) and add

$Foswiki::cfg{Plugins}{AutoTemplatePlugin}{ViewTemplateRules} = {
  'WebChanges' => 'WebChangesView',
  'SiteChanges' => 'SiteChangesView',
  'WebSearch' => 'SolrSearchView',

to your Foswiki configuration.

-- MichaelDaum - 30 May 2012

Support.FAQForm edit

TopicClassification FrequentlyAskedQuestion
Subject Extension, Search
Topic Summary
Extension SolrPlugin
Interested Parties
Related Topics
Topic revision: r3 - 30 May 2012, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy