Unable to get expected results by using CQL
Asked by webmethods-integration:

Hi

Below mentioned is the query I am using to find content/page based on page id, watcher and accountId of the member who has recently updated the page.
>
> ```
> https://wmio12.atlassian.net/wiki/rest/api/content/search?cql=id=370802698 and contributor.accountid = '5cab1f74faab36165eb9cda1' and watcher.accountId ='5bc7427f65a8021356ab9f2a'
> ```

**Issue related to Contributor field**

Went through the [CQL Advance searching](https://developer.atlassian.com/server/confluence/cql-field-reference/) Document and discovered that CQL field contributor.accountId works for both i.e created and editor.

So is there any key through with I can filter pages based on accountId of the user who has recently updated the page.

**Issue related to Watcher field**

In all other scenarios, the CQL watcher field works fine and returns proper results but when I pass creator accountID as a value to CQL watcher.accountId field the Query always returns result even if no watcher is watching the page.

So can some help me with this?

Regards,

Kuldeep Kushwaha


Answers:
author: Diego
body: Hello [@webmethods-integration](/t5/user/viewprofilepage/user-id/3192373) !

As I understand, you are currently facing some issues while creating a CQL query and sending it via REST to Confluence on the Cloud.

To try and address your first question:
> *"So is there any key through with I can filter pages based on accountId of the user who has recently updated the page."*

I got this query:
> *[https://myconfluence.atlassian.net/wiki/rest/api/content/search?cql=lastModified\>=2020-07-07%AND%contributor="668085:c45b1b9b-1d3d-5579-9e20-cc175cb2000d](https://myconfluence.atlassian.net/wiki/rest/api/content/search?cql=lastModified>=2020-07-07%AND%contributor="668085:c45b1b9b-1d3d-5579-9e20-cc175cb2000d)"*

You can swap the actual date (in the example above 2020-07-07) with one of these functions:
> * *endOfDay()*
> * *endOfMonth()*
> * *endOfWeek()*
> * *endOfYear()*
> * *startOfDay()*
> * *startOfMonth()*
> * *startOfWeek()*
> * *startOfYear()*

And in place of the accountID value for the contributor field, you could use:
> *contributor.fullname="Contributor Fullname"*

Where "Contributor Fullname" should be replaced with the actual user's full name.

The query used as an example will look for content which the lastModified date (last time someone edited that content) that is bigger or equal to 2020-07-07 and has the contributor set to the specified accountID.

You can look for more details about the CQL Field here:
> * [**++*\[Confluence Cloud Developer\] CQL Field*++**](https://developer.atlassian.com/cloud/confluence/cql-fields/#lastmodified)

The second situation might be addressed by this bug:
> * [++***\[Confluence Cloud\] Searching for watcher field via CQL yields incorrect results***++](https://jira.atlassian.com/browse/CONFCLOUD-70064)

It seems that the Watch and Stop Watching actions do not trigger a reindex of the current content. I was able to replicate the behavior you explained and worked around it by using the "*Star this page*" action on the same page I was querying with CQL. The star action is triggered by clicking the start icon at the top right corner.

The "*Star this page*" action did trigger the reindex and when I sent the same query to look for content with watchers, the result was updated.

Let us hear from you!

comments: author: josef
body: Bug in 2nd situation should be fixed now


Tags: cloud

confluence-cloud

cql