brandonscript
brandonscript

Reputation: 73005

In Apigee App Services, can you query an array element?

Let's say I've got an App Services entity with the following data:

...
times: [
    "3/05/2014 18:00:00",
    "3/06/2014 16:00:00",
],
...

Using query operators, is there a way to reference a particular numbered element in the array?

I've tried the following:

select * where times.0 > '3/05/2014 18:00:00' //this one returns no data
select * where times[0] > '3/05/2014 18:00:00' //this one fails with a java error

It seems that if there's one element in the array, it works fine just with:

select * where times > '3/05/2014 18:00:00'

...but not if there are more than one (nor if I wanted to check a particular numbered array element).

Upvotes: 0

Views: 170

Answers (1)

Michael Russo
Michael Russo

Reputation: 628

I was able to query this scenario without a problem using Apigee's Advanced API Services. I have a total of 5 entities in my /items collection, all having the times array. These look like:

{
  "uuid": "65d39aba-8df4-11e3-8926-f36d6fff0de6",
  "type": "items",
  "name": "testItem5",
  "created": 1391556657115,
  "modified": 1392920493819,
  "description": "This is a test item 5.",
  "id": "0005",
  "metadata": {
    "path": "/items/65d39aba-8df4-11e3-8926-f36d6fff0de6"
  },
  "times": [
    "3/05/2014 18:00:00",
    "3/06/2014 16:00:00"
  ]
}

Only 3 of the items have a value > 3/05/2014 18:00:00. When I make the below query:

/items?ql=select%20*%20where%20times%20%3E%20%273/05/2014%2018:00:00%27

or unescaped

/items?ql=select * where times > '3/05/2014 18:00:00'

the 3 items with a value higher than 3/05/2014 18:00:00 return without any problem.

Upvotes: 1

Related Questions