2

I want to search for element with key-value from array element section of the document. Lets say i have json looks like -

{ 
   "name":"abc", 
   "lastName":"xyz", 
   "description":"aaaaa aaaa", 
   "dob":11-10-1988,
   "workInformation":[
       {
          "address":"kolkata", 
          "workFor":"vvv Pvt Ltd"
       },
        {
          "address":"bangalore", 
          "workFor":"www Pvt Ltd"
       }
    ]
}

Lets say i want to search using java api inside array property workInformation for below mentioned key and value -

key - workFor, value - vvv Pvt Ltd

Please let me know, how to do it.

Thanks for reading.

1 Answer 1

6

One easy way is to use StructuredQueryBuilder.value. For example:

StructuredQueryBuilder sqb = new StructuredQueryBuilder();
QueryDefinition query = sqb.value(sqb.jsonProperty("workFor"), "vvv Pvt Ltd");

Another option is to use QBE.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.