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
Hide line numbers
1: {{velocity}} 2: #set($query = "$!request.query") 3: #set($input = "$!request.input") 4: #set($nb = "$!request.nb") 5: #if($nb != '') 6: #set($nb = $util.parseInt($nb) + 1) 7: #else 8: #set($nb = 6) 9: #end 10: #if($query != '' && $input != '') 11: #set($query = $query.replaceAll('__INPUT__', $input)) 12: #set($discard = $response.setContentType("text/xml")) 13: <?xml version="1.0" encoding="UTF-8"?> 14: #set($rawresults = $xwiki.lucene.getSearchResults($query, '', $xcontext.database, $util.null)) 15: #set($results = $rawresults.getResults("1", "$nb")) 16: <results> 17: #foreach($item in $results) 18: #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") 19: #set($itemdoc = $xwiki.getDocument($itemfullname)) 20: #if($item.type == "attachment") 21: #set($name = $item.filename) 22: #set($url = $itemdoc.getAttachmentURL($name)) 23: #else 24: #set($name = $itemdoc.getDisplayTitle()) 25: #set($url = $itemdoc.getURL()) 26: #end 27: <rs id="$url" info="${escapetool.xml($itemdoc.fullName)}">$escapetool.xml($name)</rs> 28: #end 29: </results> 30: #else 31: {{info}} 32: This service allows to retrieve search results for the suggest UI component. 33: Examples: 34: * [[$doc.getExternalURL('get', 'outputSyntax=plain&query=__INPUT__*&input=test')]] 35: {{/info}} 36: #end 37: {{/velocity}}