Query API trouble with sorting

ces55739's Avatar

ces55739

18 Feb, 2015 09:54 PM

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())
  1. 1 Posted by Ryan Griffith on 19 Feb, 2015 02:44 PM

    Ryan Griffith's Avatar

    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. 2 Posted by ces55739 on 19 Feb, 2015 04:24 PM

    ces55739's Avatar

    Will do. Thanks for the help Ryan!

  3. ces55739 closed this discussion on 19 Feb, 2015 04:24 PM.

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

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM