Tags:
create new tag
view all tags

SID-02052: Search with date conditions

Status: Answered Answered TWiki version: 6.0.1 Perl version:
Category: CategorySearch Server OS: Last update: 8 years ago

Dear TWiki experts,

In our TWiki we have so-called reviewing, e.g. each page contains phrase for example '%REVIEW% AlexeyBoldyrev - 2015-04-01' or '%REVIEW% *Never reviewed*'. I want to make a search of topics with conditions 'reviewed/not reviewed' and 'before/later than YYYY-MM-DD'. How can I read YYYY-MM-DD values and use them in a search?

Many thanks, Alexey

P.S. I'm not administrator, I'm just TWiki user.

-- Alexey Boldyrev - 2015-04-10

Discussion and Answer

There is no direct support for date query in the unstructured TWiki topic text. For applications like this I recommend creating TWikiForms based apps. If you store dates in TWiki form fields you can do date based queries with a QuerySearch.

With some hoops I think it is possible to do date-based queries on the topic text. Here is the general idea:

  • Do a TWiki.Formatted search with multiple="on" to grab just the lines with %REVIEW% & date.
  • in the format="..." do a VarCALCULATE
    • The CALCULATE needs to be escaped so that it runs once per search hit, not once before the search: format="$percntCACLULATE{$IF(test, true, false)}$percnt"
  • The CACLULATE has an IF based on your date comparison.
    • If true, output a search hit line, such as | $topic | $date |.
    • If false, output just a <nop> - the nop is a no-operation that cancels the output of the current search hit.
  • To do the IF test, you first need to extract the ISO date from the line using a RegularExpression $pattern(...).
  • The queried and cutoff ISO dates need to be converted into serialized dates, then compared. The compare result is the IF test.

This should give you the basic idea how to approach the date-based search on unstructured text. As mentioned, it would be much easier with a TWikiForms based app.

-- Peter Thoeny - 2015-04-12

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the TWiki consultants if you need timely help. We invite you to get involved with the community, it is more likely you get community support if you support the open source project!

-- Peter Thoeny - 2015-12-03

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Search with date conditions
SupportCategory CategorySearch
TWiki version 6.0.1
Server OS

Web server

Perl version

Browser & version Mozilla Iceweasel 31.6.0
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2015-12-03 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.