Filter_query OR condition

Hello,

I’m using Content Delivery API and I’m wondering is there a way to filter the data in this way:

filter_query[filed_1][in_array]=1,2,3 OR filter_query[filed_2][in_array]=1,2,3

I need OR relationships between two different fields.

Thanks,
Andjela

Hello @andjela.dankic,

you can find an example of how you can achieve this here Filter for specific multiple attributes - #2 by Hannes

Best regards
Hannes

Thanks @Hannes,
This was helpful.

I’m actually trying to find a way to create filter that looks like this:

Storyblok.get(‘cdn/stories’, {
filter_query:{
“__and”: [
{
“__or”:[
{
“filed1_1”:{
“in_array”:“1,2”
}
},
{
“filed1_2”:{
“in_array”: “1”
}
}
]
},
{
“__or”:[
{
“filed2_1”:{
“in_array”:“1,2”
}
},
{
“filed2_1”:{
“in_array”: “1”
}
}
]
},
{
“component”:{
“in”:“article”
}
}
],
}
})

(filed1_1 in list OR filed1_2 in list) AND (filed2_1 in list OR filed2_2 in list) AND component=article

Is there a way to filter the data in this way, since I’m always getting the response like data were not filtered at all.

Thanks,
Andjela

Hello @andjela.dankic ,

only one of the supported queries at a time will work but you can use them to prefilter the results that you get from the API and refine the result with additional filtering your own implementation.

Best regards
Hannes