I'm using PostgreSQL 9.5 and the JSONB data type to store documents. My table something like this:
create table records (
id serial,
data jsonb
);
My documents contain an array of objects, for example:
{
"some_field": "a value",
"another_field": 123,
entries: [
{
"name": "John Doe",
"age": 42
},
{
"name": "Johnny McMuffin",
"age": 117
}
]
}
The problem is that I would like to be able to filter on the name attribute in the entries array and I just can't figure it out. I want to be able to find rows in my table that partially match one of the names in the list of objects.
I've read a lot about indexes and expressions and stuff but I just can't seem to get it to work. Shouldn't this be possible?