Query API trouble with sorting
Hi,
I am using Velocity's locator query api tool, which is super handy. However, is there a way to help limit searching? I see there is a .hasMetadata(field, value) option. But I am looking for the opposite. For our "News Articles", we do not always set our startDate in the metadata. Is there a way to get all pages that do not have a NULL value, for a given field?
Here is the code so far:
#set($query = $_.query())
#set($query = $query.byContentType("News Article"))
#set($query = $query.maxResults(-1)) ## 500 is the max at this moment.
#set($query = $query.hasMetadata('startDate', ))
#set($query = $query.sortBy('startDate'))
#set($query = $query.sortDirection('desc'))
#set($results = $query.execute())
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ryan Griffith on 19 Feb, 2015 02:44 PM
Hi,
Currently, it is only possible to filter by a specific value, or null, but not the other way around. Instead, you would need to return your results and handle the check for a null start date somewhere else, such as while you are looping over the results.
That being said, I was able to find this related suggestion on our Idea Exchange to improve the filtering capabilities of the Query API. I highly recommend voting this suggestion up if you would like to see this functionality implemented in a future release of Cascade Server.
Please let me know if you have any questions.
Thanks!
2 Posted by ces55739 on 19 Feb, 2015 04:24 PM
Will do. Thanks for the help Ryan!
ces55739 closed this discussion on 19 Feb, 2015 04:24 PM.