Cloudant Selector Query

后端 未结 2 1242
耶瑟儿~
耶瑟儿~ 2020-12-03 11:36

I would like to query using cloudant db using selector, for example that is shown below: user would like to have loanborrowed whose amount exceeds a number, how to access th

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 12:25

    If you use the default Cloudant Query index (type text, index everything):

    {
       "index": {},
       "type": "text"
    }
    

    Then the following query selector should work to find e.g. all documents with a loanamount > 1000:

    "loansBorrowed": { "$elemMatch": { "loanamount": { "$gt": 1000 } } }
    

    I'm not sure that you can coax Cloudant Query to only index nested fields within an array so, if you don't need the flexibility of the "index everything" approach, you're probably better off creating a Cloudant Search index which indexes just the specific fields you need.

提交回复
热议问题