Query on numeric property name in sub document

Hi all,

I got document who lokks like :

{
  "mobile": {
    "default": {
      "s": {
        "camp": {
          "100112": 0,
          "100114": 0,
          "100122": 0
        },
        "score": 1
      }
    }
  }
}

And I want to select document with some criteria like :

select * from my_bucket where mobile.default.s.camp.100112 = 0

But I got a syntaxe error :

[
  {
    "code": 3000,
    "msg": "syntax error - at 100112",
    "query_from_user": "select  * from `user_scoring_sample` t where mobile.default.s.camp.100112 = 0"
  }
]

Is it allowed to have numeric property name ? do we have to escape them in a n1ql query ?

try to use this one

select * from my_bucket where mobile.default.s.camp.`100112` = 0
2 Likes

Tks it works. and what kind of index do I have ton create to speed up that query ?

create index i1 on my_bucket(mobile.default.s.camp.100112`)

Somehow the formatting gets messed up. The index key should be exactly the same full field name in the WHERE clause.