JV,
We need the new search page to behave the same as the old one in term
of "features". I haven't checked your code yet (will do in a few
moments).
Here's is what it should have:
- a combo box to select the space to search in
- exclusion of some spaces if the user is not admin
- ability to pass a space in parameter
- escaping of some special characters <, >, etc
- etc
In addition is the Lucene search searching in all places that the
old hibernate search was searching in? From what I recall the old
search was looking in:
- document contents
- document names
- document object properties (string and textarea properties)
(I know the new lucene search searches in attachments too which is a
great new feature!)
Thanks
-Vincent
On Aug 12, 2007, at 9:13 PM, Jean-Vincent Drean wrote:
Author: jvdrean
Date: 2007-08-12 21:13:05 +0200 (Sun, 12 Aug 2007)
New Revision: 4208
Added:
xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/
Main/LuceneSearch
Modified:
xwiki-products/xwiki-enterprise/trunk/
xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/
XWiki/Results
Log:
XE-48 : Replace current hibernate search with the lucene plugin +
nice search page
Property changes on: xwiki-products/xwiki-enterprise/trunk
___________________________________________________________________
Name: svn:ignore
- *.iml
.project
.classpath
target
*.log
+ *.iml
.project
.classpath
target
*.log
idea
Added: xwiki-products/xwiki-enterprise/trunk/wiki/src/main/
resources/Main/LuceneSearch
===================================================================
--- xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/
Main/LuceneSearch 2007-08-12 19:12:39 UTC (rev 4207)
+++ xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/
Main/LuceneSearch 2007-08-12 19:13:05 UTC (rev 4208)
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xwikidoc>
+<web>Main</web>
+<name>LuceneSearch</name>
+<language></language>
+<defaultLanguage>en</defaultLanguage>
+<translation>0</translation>
+<parent></parent>
+<creator>XWiki.Admin</creator>
+<author>XWiki.Admin</author>
+<customClass></customClass>
+<contentAuthor>XWiki.Admin</contentAuthor>
+<creationDate>1186588178000</creationDate>
+<date>1186942604000</date>
+<contentUpdateDate>1186942604000</contentUpdateDate>
+<version>1.2</version>
+<title></title>
+<template></template>
+<defaultTemplate></defaultTemplate>
+<validationScript></validationScript>
+<comment></comment>
+<minorEdit>false</minorEdit>
+<attachment>
+<filename>next.png</filename>
+<filesize>395</filesize>
+<author>XWiki.Admin</author>
+<date>1186927318000</date>
+<version>1.1</version>
+<comment></comment>
+<content>iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/I
NwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEdSURBVDjLY/
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>
+<attachment>
+<filename>previous.png</filename>
+<filesize>389</filesize>
+<author>XWiki.Admin</author>
+<date>1186927329000</date>
+<version>1.1</version>
+<comment></comment>
+<content>iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/I
NwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEXSURBVDjLY/
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>
+<object>
+<class>
+<name>XWiki.TagClass</name>
+<customClass></customClass>
+<customMapping></customMapping>
+<defaultViewSheet></defaultViewSheet>
+<defaultEditSheet></defaultEditSheet>
+<defaultWeb></defaultWeb>
+<nameField></nameField>
+<validationScript></validationScript>
+<tags>
+<cache>0</cache>
+<displayType>input</displayType>
+<multiSelect>1</multiSelect>
+<name>tags</name>
+<number>1</number>
+<prettyName>Tags</prettyName>
+<relationalStorage>1</relationalStorage>
+<separator> </separator>
+<separators> ,|</separators>
+<size>30</size>
+<unmodifiable>0</unmodifiable>
+<values></values>
+<classType>com.xpn.xwiki.objects.classes.StaticListClass</classType>
+</tags>
+</class>
+<name>Main.LuceneSearch</name>
+<number>0</number>
+<className>XWiki.TagClass</className>
+<property>
+<tags/>
+</property>
+</object>
+<content>## ===================
+## Lucene search
+## ===================
+## Inputs : $request.text
+## Outputs : $list, $isScored
+## ===================
+
+1 Search
+
+#set($query = $request.getParameter("text"))
+#if(!$query)
+ #set($query = "")
+#end
+#set($itemsPerPage = "30")
+
+{pre}
+<form action="$doc.name" method="post">
+<input type="text" name="text" value="$query"
/>
+<input type="submit" value="Search"/>
+</form>
+{/pre}
+
+#if($query != "")
+ #set($lucene = $xwiki.getPlugin("lucene"))
+ #if($lucene)
+ ## ---------------
+ ## Lucene search
+ ## ---------------
+ #set($wikinames = "xwiki")
+ #set($languages = "default,en,de")
+ #set($firstIndex = $request.getParameter("firstIndex"))
+ #if(!$firstIndex)
+ #set($firstIndex = "1")
+ #end
+ #set($searchresults = $lucene.getSearchResults($query,
$wikinames, $languages, $xwiki))
+ #set($results = $searchresults.getResults($firstIndex,
$itemsPerPage))
+ #if($searchresults.getHitcount()>0)
+ ## -----------------
+ ## Results numbers
+ ## -----------------
+ #set($lastIndex=$searchresults.getEndIndex($firstIndex,
$itemsPerPage))
+ #if($searchresults.getHitcount()==1)
+ One result:
+ #else
+ Results $firstIndex - $lastIndex of ${searchresults.getHitcount
()}:
+ #end
+ ## ---------------
+ ## Previous page
+ ## ---------------
+ #if($searchresults.hasPrevious($firstIndex))
+ #set($linkfirstIndex = $searchresults.getPreviousIndex
($firstIndex,$itemsPerPage))
+ #set($link = "${doc.name}?text=${query}&firstIndex=$
{linkfirstIndex}")
+ {pre}
+ <a href="$link"><img src="${doc.getAttachmentURL
("previous.png")}" alt="previous" />previous
page</a>
+ {/pre}
+ #end
+ ## -------------
+ ## Next page
+ ## -------------
+ #if($searchresults.hasNext($firstIndex,$itemsPerPage))
+ #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")
+ #end
+ #else
+ Error: Lucene plugin not found.
+ #end
+#end
+
+#set($doRebuild = $request.getParameter("rebuild"))
+#if($doRebuild=="yes")
+ #set($lucene = $xwiki.getPlugin("lucene"))
+ #if($lucene)
+ #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.")
+ #else
+ #error("Error: Index rebuild failed.")
+ #end
+ #end
+#else
+ #if($xwiki.hasAdminRights())
+ #info ("[Rebuild the lucene index>${doc.web}.${doc.name}?
rebuild=yes]")
+ #end
+#end
+
+#warning("This is the new lucene search engine.\\
+ You can still use the XWiki [default search
engine>WebSearch?text=$query]..")</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-08-12 19:12:39 UTC (rev 4207)
+++ xwiki-products/xwiki-enterprise/trunk/wiki/src/main/resources/
XWiki/Results 2007-08-12 19:13:05 UTC (rev 4208)
@@ -12,14 +12,15 @@
<customClass></customClass>
<contentAuthor>XWiki.Admin</contentAuthor>
<creationDate>1158300067000</creationDate>
-<date>1180527554000</date>
-<contentUpdateDate>1180527554000</contentUpdateDate>
-<version>1.4</version>
+<date>1186942158000</date>
+<contentUpdateDate>1186942158000</contentUpdateDate>
+<version>1.5</version>
<title></title>
<template></template>
<defaultTemplate></defaultTemplate>
<validationScript></validationScript>
<comment></comment>
+<minorEdit>false</minorEdit>
<object>
<class>
<name>XWiki.TagClass</name>
@@ -31,18 +32,18 @@
<nameField></nameField>
<validationScript></validationScript>
<tags>
+<cache>0</cache>
+<displayType>input</displayType>
+<multiSelect>1</multiSelect>
<name>tags</name>
+<number>1</number>
<prettyName>Tags</prettyName>
-<unmodifiable>0</unmodifiable>
<relationalStorage>1</relationalStorage>
-<displayType>input</displayType>
-<multiSelect>1</multiSelect>
-<size>30</size>
<separator> </separator>
-<cache>0</cache>
<separators> ,|</separators>
+<size>30</size>
+<unmodifiable>0</unmodifiable>
<values></values>
-<number>1</number>
<classType>com.xpn.xwiki.objects.classes.StaticListClass</classType>
</tags>
</class>
@@ -67,14 +68,21 @@
<th style="width:150px"
class="selectFilter">Space</
th>
<th style="width:150px">Date</th>
<th style="width:150px">Last Author</th>
+ #if($isScored)
+ <th style="width:150px">Score</th>
+ #end
#if($xwiki.hasAdminRights())
<th style="width:210px" class="unsortable
noFilter">Actions</th>
#end
</tr>
#foreach ($item in $list)
- #set($troubi ="non")
+ #set($troubi = "non")
#if ($xwiki.hasAccessLevel("view", $context.user, "$
{context.database}:${item}"))
- #set($bentrydoc = $xwiki.getDocument($item))
+ #if ($item.class == "class java.lang.String")
+ #set($bentrydoc = $xwiki.getDocument($item))
+ #elseif ($item.class == "class
com.xpn.xwiki.plugin.lucene.SearchResult")
+ #set($bentrydoc = $item)
+ #end
#set($cclass = $xwiki.getDocument
("XWiki.XWikiComments").getxWikiClass())
#set($comment = $cclass.newObject())
#if($xwiki.getWebPreferenceAsInt("commentsorder",1)==0)
@@ -84,7 +92,7 @@
#end
#set($createur = $xwiki.getUserName($bentrydoc.author))
#set($ptitle = $bentrydoc.getDisplayTitle())
- <tr><td style="text-align:left">
+ <tr><td style="text-align:left">
#if($comments.size()>0)
#set($i = 0)
#set($cobj = $comments.get($i))
@@ -103,13 +111,17 @@
#else
[$bentrydoc.name>${bentrydoc.web}.
$bentrydoc.name] #if ($ptitle != $bentrydoc.name) <em>-
$ptitle</em>#end
#end
+ ## LUCENE : entries are typed
+ #elseif ($bentrydoc.type == "attachment")
+ <a href="${bentrydoc.url}"
target="_blank"><img
src="${xwiki.getSkinFile("disk.png")}"
ALT="download"> ${bentrydoc.filename}</a>\\
+ Attachment of [${bentrydoc.web}.${bentrydoc.name}]
#else
#set($comment = "")
[$bentrydoc.name>${bentrydoc.web}.
$bentrydoc.name.replaceAll("@","%40")] #if ($ptitle !=
$bentrydoc.name) <em>- $ptitle</em>#end
#end
</td><td style="text-align:left">
[$bentrydoc.web>${bentrydoc.web}.WebHome]
- </td><td style="text-align:left">
+ </td><td style="text-align:left">
$xwiki.formatDate($bentrydoc.date,"yyyy MMM dd") at
$xwiki.formatDate($bentrydoc.date,"HH:mm")</td><td
style="text-align:center">
#if($troubi =="oui")
#set($createur = $xwiki.getUserName($cobj.author) )
@@ -120,6 +132,21 @@
$createur
#end
</td>
+ #if ($isScored)
+ <td style="text-align:left">
+ #set($resval=$bentrydoc.score*100)
+ #set($starurl=$xwiki.getSkinFile("star.png"))
+ #set($star = "<img src='$starurl'
alt='$resval'>")
+ <span
class="hidden">$bentrydoc.score</span>
+ #if($resval>10) $star #end
+ #if($resval>20) $star #end
+ #if($resval>40) $star #end
+ #if($resval>60) $star #end
+ #if($resval>90) $star #end
+ #set ($perc = $resval.toString())
+ ${perc.substring(0, $perc.indexOf("."))}%
+ </td>
+ #end
#if($xwiki.hasAdminRights())
<td>
<a href="$xwiki.getURL("XWiki.CopyDocument",
"view",
"sourcedoc=${bentrydoc.fullName}")">Copy</a> -
<a
href="$bentrydoc.getURL("delete")">Delete</a> -
<a href="$bentrydoc.getURL("view",
"xpage=rename&amp;step=1")">Rename</a> -
<a
href="$bentrydoc.getURL("edit",
"editor=rights")">Rights</a>
--
You receive this message as a subscriber of the xwiki-
commits(a)objectweb.org mailing list.
To unsubscribe: mailto:xwiki-commits-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page:
http://www.objectweb.org/
wws