muruga
muruga

Reputation: 41

wildcards in cloudant query json

I have created a cloudant Query index --json, for a field in a cloudant DB. But I am not able to use the wildcards in the selector of the cloudant query. ex: priority field can take the values a,b,c,d,e,f...z In the selector below I am trying to retrieve all the records in the DB and then sort it on priority itself.. but when I use the wildcards, it is not returning results at all.

{
  "selector": {
    "priority":"*"
  },
  "sort": [
    {
      "priority": "asc"
    }
  ]
}

Please tell me which wildcard need to be used to retrieve all the docs

Upvotes: 1

Views: 992

Answers (1)

vabarbosa
vabarbosa

Reputation: 706

you may want to try using the $regex selector

{
  "selector": {
    "_id": {
      "$gt": 0
    },
    "priority": {
      "$regex": ".*"
    },
    "sort": [
      {
        "priority": "asc"
      }
    ]
  }
}

additional information about $regex can be found here:

https://docs.cloudant.com/cloudant_query.html#creating-selector-expressions

Upvotes: 2

Related Questions