General Actions:
Log-in
Register
Wiki:
games
▼
:
Document Index
»
Space:
XWiki
▼
:
Document Index
»
Page:
SuggestLuceneService
Search
en
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Wiki Home
»
SearchCode
»
Lucene Suggestion Service
Wiki source code of
Lucene Suggestion Service
Last modified by
Administrator
on 2011/11/06 20:09
Content
·
Comments
(0)
·
Annotations
(0)
·
Attachments
(0)
·
History
·
Information
Show line numbers
{{velocity}} #set($query = "$!request.query") #set($input = "$!request.input") #set($nb = "$!request.nb") #if($nb != '') #set($nb = $util.parseInt($nb) + 1) #else #set($nb = 6) #end #if($query != '' && $input != '') #set($query = $query.replaceAll('__INPUT__', $input)) #set($discard = $response.setContentType("text/xml")) <?xml version="1.0" encoding="UTF-8"?> #set($rawresults = $xwiki.lucene.getSearchResults($query, '', $xcontext.database, $util.null)) #set($results = $rawresults.getResults("1", "$nb")) <results> #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end <rs id="$url" info="${escapetool.xml($itemdoc.fullName)}">$escapetool.xml($name)</rs> #end </results> #else {{info}} This service allows to retrieve search results for the suggest UI component. Examples: * [[$doc.getExternalURL('get', 'outputSyntax=plain&query=__INPUT__*&input=test')]] {{/info}} #end {{/velocity}}