This question about Topic Markup Language and applications: Answered

Query Search: Child not found after setting new topic parent

Hi folks,

I want to display a list of child topics using this query search:
%SEARCH{"parent.name='%TOPIC%'" web="%WEB%" type="query" nonoise="on" format="   * $topic"}%

First the above code seemed to work properly, but then I noticed that some child topics are missing in the resulting list. After investigation I found out the circumstances: When I set a new parent for a topic, the search in the new parent does not include the new child. The old parents search doesn't include the topic either (anymore).

I guess this is a bug, but it might be some misunderstanding on my part. In cases like this, should I directly file a bug report in the future or is it (for some reason) better to ask a support question here?

Thanks!

-- EinExperte - 29 Dec 2017

The other logical explanation is that the parent isn't '%TOPIC%' but some equivalent such as '%WEB%.%TOPIC%'.

-- MichaelDaum - 29 Dec 2017

You can check the PARENT information in the topic metadata. If you view the topic with the ?raw=all URL param, it will dump the topic file, (or just look at the .txt file on disk if you have server access.) It''s the 2nd line in the file, and starts with a % - percent sign (omitted from this example)

 META:TOPICPARENT{name="MyParent"}%

-- GeorgeClark - 30 Dec 2017

I checked the Metadata using the url parameter George suggested and Michael was right: After renaming a topic, it's stored as Web.Topic (even though I didn't specify the web part).

So I adjusted the query. With this one I get all the children:
%SEARCH{"parent.name='%TOPIC%' OR parent.name='%WEB%.%TOPIC%'" web="%WEB%" type="query" nonoise="on" format="   * $topic"}%

Maybe someone can update the manual in QuerySearch#Search_examples because the exact query that fails / is incomplete is listed there as the first example and is supposed to "Find all topics that are children of this topic in the current web ", which it doesn't.

-- EinExperte - 03 Jan 2018

Fixed under the Documentation task Item13883 for Foswiki 2.1.5
diff --git a/core/data/System/QuerySearch.txt b/core/data/System/QuerySearch.txt
index 81780f9..5b6d403 100644
--- a/core/data/System/QuerySearch.txt
+++ b/core/data/System/QuerySearch.txt
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="ProjectContributor" date="1480472285" format="1.1" version="1"}%
+%META:TOPICINFO{author="ProjectContributor" date="1515946105" format="1.1" version="1"}%
 %META:TOPICPARENT{name="UserDocumentationCategory"}%
 %STARTINCLUDE%
 ---+ Query Search
@@ -234,9 +234,9 @@ will return an array of the values of the Published field in all versions author
    * =lc(name)=~'.*ann.*'= - Would match Anne, Maryann, !MaryAnn,  !AnnMarie...
 
 ---+++ Search examples
-Find all topics that are children of this topic in the current web
+Find all topics that are children of this topic in the current web. (The parent can be stored with or without the web name. The web name is typically added if a topic or its parent is moved/renamed.)
 <verbatim class="tml">
-%SEARCH{"parent.name = '%TOPIC%'" web="%WEB%" type="query"}%
+%SEARCH{"parent.name='%TOPIC%' OR parent.name='%WEB%.%TOPIC%'" web="%WEB%" type="query"}%
 </verbatim>
 Find all topics that have an attachment called 'grunge.gif'
 <verbatim class="tml">
</verbatim>

-- GeorgeClark - 14 Jan 2018
 

QuestionForm edit

Subject Topic Markup Language and applications
Extension
Version Foswiki 2.1.3
Status Answered
Related Topics
Topic revision: r6 - 14 Jan 2018, GeorgeClark - This page was cached on 17 Nov 2018 - 19:12.

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