Query

The custom Velocity template for the query uses the JCR (Java Content Repository, JSR 283) programming model. The SiteVision API is available here

Example query: find 'my pages', as defined by the user metadata named 'responsible'

Query syntax

Query strings should be expressed according to the Solr query syntax. The syntax is basically the Lucene query syntax with some minor differences. Also note that a general recommendation is to always use the prefix operators (+/-) instead of the boolean keywords (AND/OR/NOT) to avoid unexpected behaviour. For deeper understanding, see for example Why Not AND, OR, And NOT?.

Elements available in the Velocity Context (when evaluation is activated)
NameType and Description
portletjavax.jcr.Node
 This portlet. See properties below
sitevisionUtilssenselogic.sitevision.api.Utils
 The main entry point to all utility classes
jcrSessionjavax.jcr.Session
 The JCR Session
requestjavax.portlet.PortletRequest
 The portlet request

For best performance - don't refer/use the $portlet reference if you can avoid it. Creating the portlet Node is a potential expensive operation and will only be added if detected in your Velocity template code.

Additional properties available for the portlet element ($portlet)
NameType and Description 
 Querying 
predefinedSearchQueryjavax.jcr.PropertyType.STRING 
 The search query expression 
evaluatePredefinedSearchQueryjavax.jcr.PropertyType.BOOLEAN 
 Whether predefinedSearchQuery should be evaluated via Velocity or not 
   
 Type restrictions 
includeFilesjavax.jcr.PropertyType.BOOLEAN 
 Whether or not to include files in the search result 
includeImagesjavax.jcr.PropertyType.BOOLEAN 
 Whether or not to include images in the search result 
includePagesjavax.jcr.PropertyType.BOOLEAN 
 Whether or not to include pages in the search result 
includeArticlesjavax.jcr.PropertyType.BOOLEAN 
 Whether or not to include articles in the search result 
includeStructurePagesjavax.jcr.PropertyType.BOOLEAN 
 Whether or not to include structure pages in the search result 
   
 No hits / Search failed 
showSearchErrorjavax.jcr.PropertyType.BOOLEAN 
 Whether or not to show search errors or no hits messages 
errorMessagejavax.jcr.PropertyType.STRING 
 An i18n:ized message describing why search could not be executed 
searchErrorFontjavax.jcr.PropertyType.WEAKREFERENCE 
 The search error font Node (sv:font) 
   
 Index fields 
summaryFieldjavax.jcr.PropertyType.STRING 
 Name of the summary field 
titleFieldjavax.jcr.PropertyType.STRING 
 Name of the title field 
nameFieldjavax.jcr.PropertyType.STRING 
 Name of the name field 
namepathFieldjavax.jcr.PropertyType.STRING 
 Name of the name path field 
urlFieldjavax.jcr.PropertyType.STRING 
 Name of the absolute URL field 
uriFieldjavax.jcr.PropertyType.STRING 
 Name of the relative URL field 
lastPublishedFieldjavax.jcr.PropertyType.STRING 
 Name of the last published field 
sizeFieldjavax.jcr.PropertyType.STRING 
 Name of the size field 
siteFieldjavax.jcr.PropertyType.STRING 
 Name of the site field 
mimetypeFieldjavax.jcr.PropertyType.STRING 
 Name of the mime type field 
   
 Hit count 
useMaxSearchHitsjavax.jcr.PropertyType.BOOLEAN 
 Whether or not to limit number of search hits 
maxSearchHitsjavax.jcr.PropertyType.LONG 
 Maximum number of search hits 
   
 Search hits 
showSearchHitNumberingjavax.jcr.PropertyType.BOOLEAN 
 Whether or not search hits should be displayed numbered 
showFileIconsjavax.jcr.PropertyType.BOOLEAN 
 Whether or not a file icons should be displayed for each search hit 
useSearchHitBackgroundColorjavax.jcr.PropertyType.BOOLEAN 
 Whether or not a searchHitBackgroundColor (see line below) are in use 
searchHitBackgroundColorjavax.jcr.PropertyType.WEAKREFERENCE 
 The background color for every odd search hit (sv:color) 
headingFieldjavax.jcr.PropertyType.STRING 
 What field to fetch the heading text from ("nameField" or "titleField", see Index fields section above) 
searchHitHeadingFontjavax.jcr.PropertyType.WEAKREFERENCE 
 The hit heading font Node (sv:font) 
showSearchHitExcerptjavax.jcr.PropertyType.BOOLEAN 
 Whether or not to show hit excerpts 
searchHitExcerptFontjavax.jcr.PropertyType.WEAKREFERENCE 
 The hit excerpt font Node (sv:font) 
searchHitExcerptLengthjavax.jcr.PropertyType.LONG 
 Approximate length (char count) for search hit excerpts 
showSearchHitInfojavax.jcr.PropertyType.BOOLEAN 
 Whether or not to show hit info (date + size) 
searchHitInfoFontjavax.jcr.PropertyType.WEAKREFERENCE 
 The hit info font Node (sv:font) 
showSearchHitPathjavax.jcr.PropertyType.BOOLEAN 
 Whether or not to show a linked path to the search hit 
searchHitPathFontjavax.jcr.PropertyType.WEAKREFERENCE 
 The hit path font Node (sv:font) 
   
 Misc 
useCustomSortFieldsjavax.jcr.PropertyType.BOOLEAN 
 Whether or not to use custom sort fields (i.e. use a custom "relevance" sorting") 
useCustomIndexjavax.jcr.PropertyType.BOOLEAN 
 Whether or not a custom index is used 
   
 Aggregated portlet preferences/settings: 
templatesjavax.jcr.PropertyType.WEAKREFERENCE 
 A temporary Node holding all sub-templates used by the main template. See available properties in table below 
bundlejavax.jcr.PropertyType.WEAKREFERENCE 
 A temporary Node holding all i18n:ized texts used for output. See available properties in table below 

Denna sida publicerades: 2016-11-10

Skriv ut PDF-avsnitt

Hjälpte informationen på den här sidan dig?

Missa inga nya rön, tips och tricks! Prenumerera på insite!

Find us!

SiteVision AB (Headquarter)
Vasagatan 10
702 10 Orebro
Sweden

Info: +46 19-17 30 30
Support: +46 19-17 30 39

Latest Tweets