Search Functions

Using functions to run searches with the projectdoc Toolbox.

Type
Level of Experience

This tip shows the use of search functions in queries based on macros of the projectdoc Toolbox for Confluence.

Search functions provide values to pass into searches that are dependent on the context. In this tip you will learn how to refer to the current user and the current date.

Journals

For this short introduction of search functions our use case is journals. Suppose Jane and John want to work together and share their professional journals. Each journal is organized in years and days. Each day is a page in the year journal. Each day page collects events the journal owner wants to remember. Jane and John also use a common set of subjects, categories, and tags to organize their events.

User Function

Suppose Jane and John use the same view on their work. They craft a page with a couple of display tables and some links to sites that are currently interesting for their work. This page should also collect a number of days from the current user's diary.

This is what the Display Table Macro looks like in the macro editor.

Since every page has the user's full name as the value of the Author property, the currentUser function can be used to render the full name (by the use of the "fn" argument) and compare it in the search with the property value.

Date Function

Now let's assume that we only want to show the events of the last week.

$<Date§> >= ${now(-1w)}

The Date property stores the date of the day. To make it comparable to match in a search, you need to use the normalized form. Therefore refer to the artificial property Date§.

The date function now refers to the current date. To define a period of one week to now use -1w (w for week). If the date of the day is not older than one week, it will be part of the result set.

The Where parameter now has the value of

$<Author>=${currentUser("fn")} AND $<Date§> >= ${now(-1w)}

More functions?

For a list of supported search function, please refer to Supported Functions in Search Tips.

It is also possible to define ranges easily (Using Date Ranges in Search Tips):

Date§: [${now(-6w)} TO ${now(-4w)}]

Summary

This short tip showed the use of two search functions:

  1. currentUser
  2. now

These functions allow to define queries that are dependent on the current user and the current date.

Resources

Links to related information.

Search Tips
Tips on specifying search queries for Lucene. This also applies to projectdoc's query macros.
Remote Control
Supports Remote Controlled Documents by making parameters accessible via request parameters.
Display Table Macro
Lists references to projectdoc documents in a table. Allows to select document properties for columns. Also non-list representations are provided.