This question about Documentation: Answered

Combined search over content AND form data?

I've got a documentation wiki where pages have a dataform attached. I want to build a search that matches a specific topic text and a specific dataform value:

  1. The form contains a ContentOwner field, and it's possible to list all pages for a given owner using a search:
    %SEARCH{
      type="query"
      "DocumentationForm[name='ContentOwner'].value='%WIKINAME%'"
      nosearch="on"
      order="topic"
      limit="all"
      excludetopic="%TOPIC%"
      header="| *Topic* | *Last updated* | *By* |"
      format="| [[%BASEWEB%.$topic][$topic]] | $date | $wikiname |"
    }%
  2. Incomplete topics have the text string TODO in them. It's easy to build a search for any pages that contain this text.

Question: How do I combine the two searches?* How do I search for dataform value owner = currently logged-in user and topic text TODO?

I've tried a nested search (outer search for owner in dataform, inner search for text in topic) but I fail to get correct results. Instead, the result is either two results after each other, or the inner search is executed as many times as there are results in the outer search! Because I do get results, I think that I'm writing the search correctly, but it's the wrong search.

Separate from the above, I want to create a search that matches specific values in two dataform fields. Is that also achieved with nested search?

-- TorbenGB - 20 Aug 2010

I've been able to answer my secondary question about matching two dataform fields, but not the primary question about matching text AND dataform. Here's how to search for two dataform field matches:
  • Since both criteria are in the dataform, I can use a single search, and use the AND operator in the query:
    %SEARCH{
      type="query"
      "DocumentationForm[name='ContentOwner'].value='%WIKINAME%' 
        AND DocumentationForm[name='DocumentationStatus'].value='DraftStatus'"
      nosearch="on"
      order="topic"
      limit="all"
      excludetopic="%TOPIC%"
      separator=", " format="[[%BASEWEB%.$topic][$topic]]"
    }%

-- TorbenGB - 20 Aug 2010

You can also apply your solution to the 1st problem:

%SEARCH{
  type="query"
  "DocumentationForm[name='ContentOwner'].value='%WIKINAME%' AND text ~ '* TODO *'"
  nosearch="on"
  order="topic"
  limit="all"
  excludetopic="%TOPIC%"
  header="| *Topic* | *Last updated* | *By* |"
  format="| [[%BASEWEB%.$topic][$topic]] | $date | $wikiname |"
}%

-- MartinKaufmann - 20 Aug 2010

Yippie, that's perfect! Thank you Martin! The trick I didn't know was AND text ~ '*value*'.

-- TorbenGB - 23 Aug 2010

Thank you for the code highlighting, PaulHarvey. Looks great!

-- TorbenGB - 24 Aug 2010

QuestionForm edit

Subject Documentation
Version Foswiki 1.0.9
Status Answered
Topic revision: r7 - 21 Dec 2010, TorbenGB
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy