Exclude-Self doesn't work in DisplayMacro
Asked by Jose Galiana:

When I use DisplayTable macro the "Exclude-Self" option doesn't work fine, because it shows current page instead of exclude it.

<br />

I've seen the lucene query something like "AND -PageID:5075807" when "Exclude-Self" is true. Instead of that, I write Where clause like "PageID NOT 5075807" and works fine.

Can be a possible bug?  
[](https://community.atlassian.com/t5/Confluence-questions/Exclude-Self-doesn-t-work-in-DisplayMacro/qaq-p/393572?attachment-id=11640){#link_1186e86af88ecb}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/66666/1/image2016-5-13%2011%3A8%3A53.png){#display_1186e86af88ecb_0}  
[](https://community.atlassian.com/t5/Confluence-questions/Exclude-Self-doesn-t-work-in-DisplayMacro/qaq-p/393572?attachment-id=11641){#link_1186e86af88ecb_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/66666/2/ExcludeSelf-true.jpg){#display_1186e86af88ecb_2}  
[](https://community.atlassian.com/t5/Confluence-questions/Exclude-Self-doesn-t-work-in-DisplayMacro/qaq-p/393572?attachment-id=11642){#link_1186e86af88ecb_1}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/66666/3/PageID_no_term.jpg){#display_1186e86af88ecb_4}  
[](https://community.atlassian.com/t5/Confluence-questions/Exclude-Self-doesn-t-work-in-DisplayMacro/qaq-p/393572?attachment-id=11643){#link_1186e86af88ecb_2}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/66666/4/DirectAncestorID_no_term.jpg){#display_1186e86af88ecb_6}  
[](https://community.atlassian.com/t5/Confluence-questions/Exclude-Self-doesn-t-work-in-DisplayMacro/qaq-p/393572?attachment-id=11644){#link_1186e86af88ecb_3}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/66666/5/image2016-5-13%2011%3A8%3A18.png){#display_1186e86af88ecb_8}  
[](https://community.atlassian.com/t5/Confluence-questions/Exclude-Self-doesn-t-work-in-DisplayMacro/qaq-p/393572?attachment-id=11645){#link_1186e86af88ecb_4}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/66666/6/and-.png){#display_1186e86af88ecb_10}  
[](https://community.atlassian.com/t5/Confluence-questions/Exclude-Self-doesn-t-work-in-DisplayMacro/qaq-p/393572?attachment-id=11646){#link_1186e86af88ecb_5}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/66666/7/andnot.png){#display_1186e86af88ecb_12}


Answers:
author: Jose Galiana
body: We are using Confluence 5.9.8 and projectdoc toolbos 1.10.3

The query doesn't work is:

query=(DirectAncestorId:50758072 AND -PageID:50758072) AND (DoctypeExact:\&quot;userxcharacter\&quot;),category=\&lt;null\&gt;,spaceKeys=\&lt;null\&gt;,contentTypes=\[page\],attachmentTypes=\&lt;null\&gt;,lastModified=\&lt;null\&gt;,contributor=\&lt;null\&gt;,labels=\&lt;null\&gt;,sort=\&lt;null\&gt;\]

I unchecked Exclude-Self option and I write "PageID NOT 50758072" in Where field, then the query is:

query=(DirectAncestorId:50758072 AND PageID NOT 50758072) AND (DoctypeExact:\&quot;userxcharacter\&quot;),category=\&lt;null\&gt;,spaceKeys=\&lt;null\&gt;,contentTypes=\[page\],attachmentTypes=\&lt;null\&gt;,lastModified=\&lt;null\&gt;,contributor=\&lt;null\&gt;,labels=\&lt;null\&gt;,sort=\&lt;null\&gt;\]

This query works as expected.

I've just to update projectdoc toolbox to version 1.11.0 and the issue is the same.

comments: author: Robert Reiner _smartics_
body: Thank you for your report!

I'm sorry to say that I still need your help to track this down.

To my knowledge these are valid queries:

* Doctype="user-character" NOT PageID=41451771
* Doctype="user-character" AND -PageID:41451771

But this is not

* Doctype="user-character" AND PageID NOT 41451771

While the first two create the intended results (the page with the given ID is excluded), the last example shows the empty list (which is wrong since I have three documents of type 'user-character').

Here are the screenshots:  

image2016-5-13 11:8:18.png

The above shows the query with all documents in the result.  

image2016-5-13 11:8:53.png

It would help us to track the problem down if you could describe your use case.

* What documents do you have?
* What does your query need to select?

Maybe the pages have been moved by third party add-ons? In some cases theses add-ons do not throw page events and projectdoc does not get noticed. In this case the properties may not have been updated. You could check the actual properties of the pages by the use of the [Display All Document Properties Macro](https://www.smartics.eu/confluence/x/wwBz). Maybe the artificial `Page ID` property is out of sync? Just in case: Documentation for cache clearing is found in [Cache Refresh Actions](https://www.smartics.eu/confluence/x/TYGj).  

And while I'm clutching at straws ... ![sad](/html/@C495B4504065515364EB1894F812B34C/images/emoticons/sad.png "sad"): The page ID of your first example is a prefix of your second. Is the '2' just missing or are pages with a common Page ID prefix involved? In this case the exact match syntax could help (`$<Page ID>:[41451685]`).  

Here are some examples in storage format we tested (and did not reveal the problem). Maybe you could point to the fault in our setup?  

```
&lt;ac:structured-macro ac:name="projectdoc-display-table"&gt;  &lt;ac:parameter ac:name="doctype"&gt;topic&lt;/ac:parameter&gt;  &lt;ac:parameter ac:name="where"&gt;DirectAncestorId=15597571 AND -PageID:15597579&lt;/ac:parameter&gt;  &lt;ac:parameter ac:name="exclude-self"&gt;false&lt;/ac:parameter&gt;&lt;/ac:structured-macro&gt;
```

```
&lt;ac:structured-macro ac:name="projectdoc-display-table"&gt;        &lt;ac:parameter ac:name="doctype"&gt;topic&lt;/ac:parameter&gt;        &lt;ac:parameter ac:name="where"&gt;DirectAncestorId=15597571 NOT PageID=15597579&lt;/ac:parameter&gt;        &lt;ac:parameter ac:name="exclude-self"&gt;false&lt;/ac:parameter&gt;      &lt;/ac:structured-macro&gt;
```

```
 
```


author: Robert Reiner _smartics_
body: Just another observation: I suppose that

```
DirectAncestorId:50758072  AND -PageID:50758072
```

should have the same result as

```
DirectAncestorId:50758072
```

Since no page should be the direct ancestor of itself. Therefore there should be no need to exclude the page from the list ...

Or am I missing here something?


author: Jose Galiana
body: Robert, you're right and I'm wrong. The second query doesn't return any results, meanwhile "NOT PageID=50758072" (sorry, the last 2 was removed by copy/paste) returns several documents.

I've tried to retrieve subordinates UserCharacters from a UserCharacter parent. The macro shows all subordinates UserCharacters and the self UserCharacter parent. But this occurs with whatever document type.

When I use DisplayMacro, always retrieves the self document, no matter Exclude-Sefl option is checked or not. For example, subordinates UserStory also shows the UserStory parent, even if Exclude-Sef is true.

I 've cleared all caches and the issue persists.

Also, If I put "Exclude-Self" and "Restrict to inmediate Children" to false and I write "DirectAncestorId:50758087 AND -PageID:50758087" it shows the self document.


author: Robert Reiner _smartics_
body: So I'm afraid I have still no clue ... ![sad](/html/@C495B4504065515364EB1894F812B34C/images/emoticons/sad.png "sad")

May I ask you for the following:

1. The macro in XML (storage format: `<``ac:structured-macro` ...) so that I can see all parameters and therefore can rule out that I make invalid assumptions
2. A table with the `Page ID` and `DirectAncestorId` information for the involved pages (using e.g. the [Display All Document Properties Macro](https://www.smartics.eu/confluence/x/wwBz))
3. List of pages (page IDs) in the result set of the Display Table Macro

I'm very sorry for this inconvenience, but I still cannot reproduce the problem ...

And just in case ... if you add

```
NOT PageID=50758087
```

to the WHERE field (without anything else) it is the same as

```
PageID=50758087
```

The stopword "`NOT`" is simply removed. This is because Lucene requires to have a positive selection before a negative one is allowed. But this does not explain why checking the Exclude Self option has no effect ...

Does the following have the same (unwanted) result in your configuration?

```
Doctype:user-character AND -PageID:50758087
```

(or `50758072` instead of `50758087`)


author: Jose Galiana
body: At last, I use Luke to see the Confluence index and I notice that DirectAncestorId and ParentID aren't indexed although they are stored.

Using Luke search tab I cannot retrieve any results for "PageID:507580872" or "DirectAncestorID:507580872".

PageID_no_term.jpgDirectAncestorID_no_term.jpg

I clear cach?, reindex the content and anything works


author: Robert Reiner _smartics_
body: Thank you for the update!

The `Page ID` has been introduced with version 1.5 (28th March 2015). Prior to this the identifier has been stored by the key `ID`. Maybe the page has been created with an older version? Evidence is that after a reindex the queries - as you reported - are working.

The problem seems to be that we did not clearly state in the release notes that a reindex is required. We'll track this issue more carefully in the future.


author: Jose Galiana
body: Finally, I found the problem. The indexing Language (in General Configuration) was selected "Other" from the dropdown list. I changed to English and reindexed the content.

Now, Display Table Macro works as expected!!!


author: Robert Reiner _smartics_
body: We have tested the Exclude-Self feature with the latest projectdoc Toolbox (version 1.10.3) on Confluence 5.9.10 and (unfortunately) it works as intended (using the syntax "... `AND -PageID:5075807` ...).

May I ask you for the version of the projectdoc Toolbox and Confluence so that we could try to reproduce the problem? It would also help if you could add the query you are executing. Maybe there is a problem with the construction of the query. We tried some combinations, but everything worked fine.


Tags: macro