• Danilo Oliveira
    Danilo Oliveira, 2014/07/17 23:48

    If you need retrieve random results from some search you can try to use the random parameter in the SQL statement. For example, in the example below we retrieve 2 docs of a specific class randomly:

    #set($hql0 = ", BaseObject as obj where doc.fullName = obj.name and doc.fullName != 'Filmes.FilmesTemplate' and (obj.className = 'Filmes.FilmesClass') order by rand() desc")
    #set ($listProjetos = $services.query.hql($hql0).setLimit(2).execute())
    $listProjetos
  • Thomas Menamparampan
    Thomas Menamparampan, 2018/06/01 03:35

    if you need to search for not tagged pages in your wiki and have a page listed with hyperlink please do this:

    ##The query pulls out every pages that has any tag and then put into a list
    #set ($list2 = $services.query.xwql("from doc.object(XWiki.TagClass) as tag").execute() )
    ##The query pulls out every pages that was created since September 2017 and then put into a list
    #set ($list1 = $services.query.xwql("where doc.creationDate > :date").bindValue('date', $datetool.toDate('yyyy-MM-dd', '2017-09-01')).execute() )

    ##create a new list using for loop to get all items that are in list 1 but not in list 2 and call it as list3
    #set ($list3 = [])
    #foreach($ref1 in $list1)
      #set ($found = false)
      #foreach($ref2 in $list2)
        #if ($ref1 == $ref2)
          #set ($found = true)
        #end
      #end
      #if ($found == false)
        #set ($temp = $list3.add($ref1))  
      #end
    #end
    ##creation of list of pages with hyperlink for the new list3 (pages with no tags)
     #foreach($reference in $list3)
    #set ($document = $xwiki.getDocument($reference))
    #set ($label = $document.getTitle())
      [[$label>>$reference]]
    #end 

Get Connected