REST API query $or doesnt seem to properly work

I’m trying to use $or query to implement multiple filter.

I have page model

I tried both JS and REST API

const data = await builder.getAll(model, {
fields: ‘data’,
options: { noTargeting: true },
query: {
‘data.$or’: [
{ title: { $regex: ‘Dave’, $options: ‘i’ } },
{ description: { $regex: ‘expert’, $options: ‘i’ } },
{ tags: { $in: [‘history’] } }
]
}
})

return data;


const data = await fetch(https://cdn.builder.io/api/v3/content/${model}?apiKey=${BUILDER_API_KEY}&query.data.$or={title={ $regex: 'mother', $options: 'i' },{ description: { $regex: 'expert', $options: 'i' } }})
const { results } = await data.json();

return results;

please help if this is working. if this is not working is there a way to do this same logic?

Hello @djkenneth,

Welcome to the builder.io forum post.

For help on using $or please refer to our doc

You may also find help at our forum post

the reference you send. I check it and we are the same issue. The $or qeury is not wotking and I already check the doc multiple times. I tried every scenario.

    query: {
        'data.title': { $regex: 'Dave', $options: 'i' },
        'data.description': { $regex: 'cook', $options: 'i' }
    },

query: {
‘data.$or’: [
{ title: { $regex: ‘Dave’, $options: ‘i’ } },
{ description: { $regex: ‘Dave’, $options: ‘i’ } },
{ tags: { $in: [‘american’] } }
]
}

query: {
‘data.$and’: {
‘title’: { $regex: ‘Dave’, $options: ‘i’ },
‘description’: { $regex: ‘Dave’, $options: ‘i’ },
}
}


https://cdn.builder.io/api/v3/content/${model}?apiKey=${BUILDER_API_KEY}&query.data.title.$regex=Dave&query.data.title.$options=i&query.data.description.$regex=cook&query.data.description.$options=i

I need to use $or or $and query

Hello @djkenneth,

Here is an example that is working for us

  const articles = await builder.getAll('blog-article', {
    // Include references, like the `author` ref
    options: { includeRefs: true },
    limit: articlesPerPage,
    query: {
      'data': { 
        "$or": [ 
          { 
            "title": { "$eq": "Qwik Blog" }
          }, 
          { 
            "title": { "$eq": "Partytown blog" }
          }
        ]
      }
    }    
  })

Hi @manish-sharma , please provide the rest api example as well :).
Thanks in advance