Skip to content

How to query for content inside an array #4

@heiglandreas

Description

@heiglandreas

Given a document inside the document store with the following content:

{
  "state" : {
    "key1" : "value1",
    "key2" : [{
      "subkey" : "value 1"
    }, {
      "subkey" : "value 2"
    }],
    "key3" : "value3"
    }
}

How can I retrieve that document from the document store using value 2 for subkey inside key2?

For key1 and key3 i'd use the following code:

$filter = new EqFilter('state.key1', 'value1');
$filter = new EqFilter('state.key3', 'value3');

But how would I go for value 2?

I tried the following to no avail:

$filter = new EqFilter('state.key2.subkey', 'value 1');
$filter = new EqFilter('state.key2.[].subkey', 'value 1');

What am I missing? Do I by chance need to use the ArrayFilter instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions