On 07/27/2011 05:24 AM, 许凌志(Jamesxu) wrote:
I found that if there is no input for lucene query, no
results will be
returned. But In link suggestion, when user first type "[[", there is no
queries, so no suggestions will be got, but Marius and I excepted there is a
default suggestion results for users, like the recent modified pages, and
the attachments belong to the current edited pages if exists.
Yes, this is a limitation of the Lucene engine, you can't use only * as
a query term. You should drop the filter when the query stub is empty,
for example: filename:__INPUT__* should be removed if the input is empty.
Marius give me wiki page: Panels.Recently Modified,
there is an page object
for getting the Recently Modeified pages. I have tried to enhance this
object so that it can return json results which can be used as a web
service, so I edit the content of the object of this page, the code is
below:
{{velocity}}
*#set($media = "$!request.media")*
#set ($recentlyModified = $xwiki.searchDocuments('where 1=1 order by
doc.date desc', 5, 0))
#if ($recentlyModified.size()> 0 || $showEmptyPanels)
*#if($media == 'json')
$response.setContentType("application/json")
{'test':'mytest'}*
#else
#panelheader($msg.get('panels.recentlyModified.title'))
#foreach ($docname in $recentlyModified)
#if ($xwiki.hasAccessLevel('view', $xcontext.getUser(), $docname))
#set ($rdoc = $xwiki.getDocument($docname).getTranslatedDocument())
#if ($foreach.index> 0)
(% class="pitemseparator" %) ~| (%%)##
#end
(% class="panelitem" %)[[$rdoc.plainTitle>>$rdoc]](%%)##
#end
#end
#end
#panelfooter()
#end
{{/velocity}}
as you can see, I add an parameter named "media", if the media is json, then
return the json file, otherwise the default behaviour will be executed. I
tested the code above, and the json result is not
"*{'test':'mytest'}*", but
contains some other html tags.
Can anyone tell me why?
--
Sergiu Dumitriu
http://purl.org/net/sergiu/