Hi Stuart,
Starting with XWiki 5.1 the default search engine is based on Apache
Solr and the search UI has been redesigned. The page you mentioned,
XWiki.Results, is used by Lucene and Database search but not by Solr
search. Since we're focusing on Solr, I advise you to upgrade and to
check if you have the same problem when using Solr.
Hope this helps,
Marius
On Mon, Nov 18, 2013 at 6:37 PM, Stuart Stephen
<stuart.stephen(a)tracegroup.com> wrote:
Hi,
I spent some time making my XWiki instance show a more useful list of results from the
search results, but there is a problem here as the freemarker code is unable to catch a
rendering exception (by design of freemarker) on certain searches. If there is an
exception, the user is greeted with a long wait, then no results show up at all. This
isn't really good enough for my means.
My happier solution, would be for the exception to happen and for nothing to be rendered
in the preview for this search result. I wondered if there was a better way to achieve my
goal than using the rendering mechanisms in the code below. If I can avoid or catch the
exception and keep the same functionality that I have now, then I would be in a better
position.
Code below or on StackOverflow (
http://stackoverflow.com/q/17038968/1247302). I'm
using XWIKI ENTERPRISE 5.0-MILESTONE-1.
I edited the page
http://[servername:port]/xwiki/bin/edit/XWiki/Results and then added
the code
<div class="itemOthers">
#set($outputSyntax = $xwiki.getAvailableRendererSyntax('plain',
'1.0'))
#if ($outputSyntax)
#set ($preview =
$xwiki.getDocument($itemfullname).getRenderedContent($outputSyntax))
#set ($regex = $regextool.quote($request.text))
#set ($regex_summarize =
"(?i)(?:((\w+)\W+){0,20})\b\w*$regex\w*\b(((\W+)\w+){0,20})")
#set ($regex_highlight = "(?i)($regex)")
#set ($pattern_summarize = $regextool.compile($regex_summarize))
#set ($matcher_summarize = $pattern_summarize.matcher($preview))
#foreach ( $match_loop in [0,1,2,3,4,5,6,7,8,9] )
#if ($matcher_summarize.find())
#if ($match_loop > 0)
<strong> | </strong>
#end
$escapetool.html($matcher_summarize.group(0)).replaceAll($regex_highlight,'<span
style="background-color:yellow;">$1</span>')
#end
#end
#end
</div>
Thanks,
Stuart
Disclaimer: The contents of this E-mail plus any attachment is intended for the use of
the addressee only and is confidential, proprietary and may be privileged. It will not be
binding upon Trace Group or any group company (Trace). Opinions, conclusions, contractual
obligations and other information in this message in so far as they relate to the official
business of Trace must be specifically confirmed in writing by Trace. If you are not the
intended recipient you must not copy this message or attachment, use or disclose the
contents to any other person, but are requested to telephone or E-mail the sender and
delete the message and any attachment from your system. Trace takes all reasonable
precautions to ensure that no virus or defect is transmitted via this e mail, however
Trace accepts no responsibility for any virus or defect that might arise from opening this
E-mail or attachments.
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs