Author: jvdrean
Date: 2007-10-03 19:26:41 +0200 (Wed, 03 Oct 2007)
New Revision: 5269
Modified:
xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/Main/LuceneSearch
xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/XWiki/Results
Log:
XE-97 : Improve Lucene Search page to be as good as the default search
fixed :
* Add space selection as for the default search
* Add RSS feeds on search query as for the default search
* Missing page titles in the results list as for the default list
* Remove filter for score
* Velocity errors/warns to remove when clicking on the Rebuild button
Modified:
xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/Main/LuceneSearch
===================================================================
---
xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/Main/LuceneSearch
2007-10-03 17:06:21 UTC (rev 5268)
+++
xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/Main/LuceneSearch
2007-10-03 17:26:41 UTC (rev 5269)
@@ -12,9 +12,9 @@
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1186588178000</creationDate>
-<date>1186942604000</date>
-<contentUpdateDate>1186942604000</contentUpdateDate>
-<version>1.2</version>
+<date>1191330909000</date>
+<contentUpdateDate>1191330909000</contentUpdateDate>
+<version>45.1</version>
<title></title>
<template></template>
<defaultTemplate></defaultTemplate>
@@ -25,8 +25,8 @@
<filename>next.png</filename>
<filesize>395</filesize>
<author>XWiki.Admin</author>
-<date>1186927318000</date>
-<version>1.1</version>
+<date>1191242195000</date>
+<version>1.2</version>
<comment></comment>
<content>iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEdSURBVDjLY/j//z8DJZiB6gY0rH7xpW7li3YKDHj1v2bli38lix61k2VA5fJn/9eeeP+/fcOL/wlT7/aRbEDegkf/Vxx/93/xobf/S5c8/u/ecm0eSQYkTX/4f+HBN/8nbX/xf+bul/8Tp9/9r1N0dgnRBgT33QZqfPW/YdXj/42rH//v2vjkv3fHtf9SScceEWWAc8u1/xO2Pv9fsvjB//IlD4CGPPrvXH/5v2Tksc1EGWBaful/+/on/4sW3gfGxsP/9lUX/ksEH1gj6rqdhSgDlPPO/q9b8fB/5bIH/23LL/wXD9i7kqRAlEo6+b908f3/NiXn/4t57V1EcjRKRB75b1145r+o684FZCUkMb8D/0Uct88euMxEKgYA7Ojrv4CgE7EAAAAASUVORK5CYII=</content>
</attachment>
@@ -34,8 +34,8 @@
<filename>previous.png</filename>
<filesize>389</filesize>
<author>XWiki.Admin</author>
-<date>1186927329000</date>
-<version>1.1</version>
+<date>1191242195000</date>
+<version>1.2</version>
<comment></comment>
<content>iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEXSURBVDjLY/j//z8DJZiBLgZkz37Ynjrz4ReyDEideb89afrDf5ET7v4n2YCEqXf7qpY9/T9r76v/Xu03STMgasLteaVLHv+fufvl/6k7X/y3qrlCvAHBvTeXFC54ANbctv7p/95Nz/5rFZ0nzoCAzpuPsuc++D91x4v/jasf/y9aeP9/89rH/6VTTxJngGPDtc3xU+/879789H/5kgf/02fd+V+17OF/yZhjxBmgVXCaRT3v7BqP1mv/a1Y+/J824/b/woX3/osHHSAtECVjjqy0Lb/wP2/+3f+Zs+/8F3XfS3o0inntXWSeffJ/0tRb/0Ucdv4nKyEJW25ZYBh/5L+w5fb/ZCdlQYMNs4WMt/wfuMyEDwMA0Irn/pDRT58AAAAASUVORK5CYII=</content>
</attachment>
@@ -78,24 +78,83 @@
## Inputs : $request.text
## Outputs : $list, $isScored
## ===================
-
+{pre}
+#set ($displayUI = true)
+#if ($request.xpage && $request.xpage == "rdf")
+ #set ($displayUI = false)
+#end
+## ---------------
+## Title
+## ---------------
+#if ($displayUI)
+{/pre}
1 Search
-
-#set($query = $request.getParameter("text"))
+{pre}
+#end
+## ---------------
+## Space filtering
+## ---------------
+#if($request.space && $request.space != "")
+ #set($space = $request.space)
+ #set($reqspace = "AND web:${space}")
+#else
+ #set($space = "")
+#end
+#set($spacesText = {})
+#set($spaces = $xwiki.spaces)
+#set($ok = $spacesText.put("All",""))
+#foreach($space in $spaces)
+ #set($ok = $spacesText.put($space,$space))
+#end
+## ---------------
+## Space macros
+## ---------------
+#macro(spaceoption $space $selectspace $spacesText)
+ <option value="$spacesText.get($space)" #if($selectspace ==
$spacesText.get($space))selected="selected"#end>$space</option>
+#end
+#macro(spaceselect $selectspace $spaces $spacesText)
+ <select name="space">
+ #spaceoption("All" $selectspace $spacesText)
+ #foreach($space in $spaces)
+ #spaceoption($space $selectspace $spacesText)
+ #end
+ </select>
+#end
+## ---------------
+## Query preparation
+## ---------------
+#set($text = $request.getParameter("text"))
+#set($query = $text)
#if(!$query)
#set($query = "")
#end
#set($itemsPerPage = "30")
-
-{pre}
-<form action="$doc.name" method="post">
-<div>
-<input type="text" name="text" value="$query" />
-<input type="submit" value="Search"/>
+## ---------------
+## RSS link
+## ---------------
+#set($utext = $xwiki.getURLEncoded($query))
+#if($space == "")
+ #set($url = $xwiki.getURL($doc.fullName, "view",
"xpage=rdf&amp;text=${utext}" ))
+#else
+ #set($url = $xwiki.getURL($doc.fullName, "view",
"xpage=rdf&space=$space&text=${utext}"))
+#end
+#if ($displayUI)
+<div style="float: right;">
+ <a href="$url"><img src="$xwiki.getSkinFile("icons/black-rss.png")"
style="border:0px" alt="rss icon" /></a>
</div>
+## ---------------
+## Query form
+## ---------------
+<form action="$doc.name" method="get">
+<div class="centered">
+Query <input type="text" name="text" value="$query" /> in space
#spaceselect($space $spaces $spacesText) <input type="submit"
value="Search"/>
+</div>
</form>
+#end
{/pre}
-
+## ---------------
+## Results processing
+## ---------------
#if($query != "")
#set($lucene = $xwiki.getPlugin("lucene"))
#if($lucene)
@@ -108,22 +167,24 @@
#if(!$firstIndex)
#set($firstIndex = "1")
#end
- #set($searchresults = $lucene.getSearchResults($query,
$wikinames, $languages, $xwiki))
+ #set($searchresults =
$lucene.getSearchResults("${query}$!{reqspace}", $wikinames, $languages,
$xwiki))
#set($results =
$searchresults.getResults($firstIndex,$itemsPerPage))
#if($searchresults.getHitcount()>0)
## -----------------
## Results numbers
## -----------------
- #set($lastIndex=$searchresults.getEndIndex($firstIndex,
$itemsPerPage))
+
#set($lastIndex=$searchresults.getEndIndex($firstIndex, $itemsPerPage))
+ #if ($displayUI)
#if($searchresults.getHitcount()==1)
One result:
#else
Results $firstIndex - $lastIndex of
${searchresults.getHitcount()}:
#end
+ #end
## ---------------
## Previous page
## ---------------
- #if($searchresults.hasPrevious($firstIndex))
+ #if($searchresults.hasPrevious($firstIndex) &&
$displayUI)
#set($linkfirstIndex =
$searchresults.getPreviousIndex($firstIndex,$itemsPerPage))
#set($link =
"${doc.name}?text=${query}&firstIndex=${linkfirstIndex}")
{pre}
@@ -133,26 +194,42 @@
## -------------
## Next page
## -------------
- #if($searchresults.hasNext($firstIndex,$itemsPerPage))
+ #if($searchresults.hasNext($firstIndex,$itemsPerPage)
&& $displayUI)
#set($linkfirstIndex =
$searchresults.getNextIndex($firstIndex,$itemsPerPage))
#set($link =
"${doc.name}?text=${query}&firstIndex=${linkfirstIndex}")
{pre}
<a href="$link"><img
src="${doc.getAttachmentURL("next.png")}" alt="next" />next page</a>
{/pre}
#end
-
## -----------------
## Display results
## -----------------
- #set ($list = $results)
- #set ($isScored = true)
- #includeInContext("XWiki.Results")
+ #if ($request.xpage && $request.xpage == "rdf")
+ #set ($baseurl = "http://${request.serverName}")
+ #set ($description = "RSS feed for search on
'$text'")
+ #set ($list = $xwiki.arrayList)
+ #foreach ($item in $results)
+ #if ($item.type != "attachment")
+ #set ($ok = $list.add(0,
"${item.web}.${item.name}"))
+ #end
+ #end
+ #set ($ok = $response.setContentType("text/xml"))
+ #includeInContext("XWiki.WebRssCode")
+ #else
+ #set ($list = $results)
+ #set ($isScored = true)
+ #includeInContext("XWiki.Results")
+ #end
#end
#else
#error("Lucene plugin not found. Make sure it's defined in your
xwiki.cfg file.")
#end
#end
-
+{pre}
+#if ($displayUI)
+## ---------------
+## Rebuild processing
+## ---------------
#set($lucene = $xwiki.getPlugin("lucene"))
#if($lucene)
#set($doRebuild = $request.getParameter("rebuild"))
@@ -160,19 +237,37 @@
#if($doRebuild=="yes")
#set($documentCount = $lucene.rebuildIndex($xwiki,$context))
#if(${documentCount}>=0)
- #info("Started index rebuild with $documentCount
documents.\\
- Will take some time depending on the number of
pages/attachments.")
+ {/pre}#info("Started index rebuild with $documentCount
documents.\\
+ Will take some time depending on the number of
pages/attachments."){pre}
#else
#error("Index rebuild failed.")
#end
#end
#else
- #if($xwiki.hasAdminRights())
- #info("[Rebuild the Lucene
index>${doc.web}.${doc.name}?rebuild=yes]")
+## ---------------
+## Queue & rebuild option
+## ---------------
+ #set ($queuesize = $xwiki.lucene.getQueueSize())
+ #if ($queuesize > 2)
+ #set($info1 = "Lucene is currently building its index,
${queuesize} documents in queue.")
+ #else
+ #set($info1 = "")
+ #end
+ #if($xwiki.hasAdminRights())
+ #set($info2 = " [Rebuild the Lucene
index>${doc.web}.${doc.name}?rebuild=yes].")
+ #else
+ #set($info2 = "")
#end
+ {/pre}#info("${info1}${info2}"){pre}
#end
#end
-
-#info("This is the new experimental Lucene search engine.\\
- You can still use the XWiki [default search
engine>WebSearch?text=$query].")</content>
+## ---------------
+## Comment
+## ---------------
+{/pre}
+#info("This is the new experimental Lucene search engine. \\
+ You can still use the XWiki [default search
engine>WebSearch?text=$query].")
+{pre}
+#end
+{/pre}</content>
</xwikidoc>
Modified:
xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/XWiki/Results
===================================================================
--- xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/XWiki/Results
2007-10-03 17:06:21 UTC (rev 5268)
+++ xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/XWiki/Results
2007-10-03 17:26:41 UTC (rev 5269)
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
+
<xwikidoc>
<web>XWiki</web>
<name>Results</name>
@@ -11,9 +12,9 @@
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1158300067000</creationDate>
-<date>1186993868000</date>
-<contentUpdateDate>1186993868000</contentUpdateDate>
-<version>1.6</version>
+<date>1191330859000</date>
+<contentUpdateDate>1191330859000</contentUpdateDate>
+<version>4.1</version>
<title></title>
<template></template>
<defaultTemplate></defaultTemplate>
@@ -68,7 +69,7 @@
<th style="width:150px">Date</th>
<th style="width:150px">Last Author</th>
#if($isScored)
- <th style="width:150px">Score</th>
+ <th style="width:150px" class="noFilter">>Score</th>
#end
#if($xwiki.hasAdminRights())
<th style="width:210px" class="unsortable
noFilter">Actions</th>
@@ -94,12 +95,13 @@
<tr><td style="text-align:left">
## LUCENE : entries are typed
#if ($bentrydoc.type)
+ #set ($ptitle =
$xwiki.getDocument("${bentrydoc.web}.${bentrydoc.name}").getDisplayTitle())
#if ($bentrydoc.type == "attachment")
<a href="${bentrydoc.url}" target="_blank"><img
src="${xwiki.getSkinFile("icons/search/disk.png")}" ALT="download" />
${bentrydoc.filename}</a>\\
Attachment of
#end
#end
- #if($comments.size()>0)
+ #if($comments && $comments.size()>0)
#set($i = 0)
#set($cobj = $comments.get($i))
#set($comment = $bentrydoc.display("comment", "view", $cobj))
@@ -159,5 +161,4 @@
#end
#end
</table>
-</content>
-</xwikidoc>
\ No newline at end of file
+</content></xwikidoc>
\ No newline at end of file
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications