Can someone help me with this?
Using https://cdn.builder.io/api/v3/content
I need to do a search query with three parameters
I have tried with
{
"limit": "25",
"collection": "content",
"query.published.$ne": "archived",
"query.$or[0].name.$regex": "(?i)Maxi",
"query.$or[1].data.param1.$regex": "(?i)Maxi"
"query.$or[2].data.param2.$regex": "(?i)Maxi"
}
but I got no results
If I put only
{
"limit": "25",
"collection": "content",
"query.published.$ne": "archived",
"query.$or[0].name.$regex": "(?i)Maxi"
}
I got results
once I separate the query it brings results, all together, no results
thanks in advance
Hello @Shintaro ,
Welcome to the builder.io forum.
Below is an example that does query search based on multiple fields
{
'query.name.$eq': 'Qwik Blog 2023',
'query.published.$ne': 'archived',
}
const articles = await builder.getAll("blog-article", {
limit: 30,
query:{
'name': {$ne: 'Qwik Blog 2023'},
'lastUpdated': {$ne: "1686026776524"},
},
});
Hi @matheusnogueira
unfortunately, the syntax you referred to didn’t work.
But I tried to change my query for the topic.
// it works
{ "topic.id": { $eq: "..." } }
// it doesn't work
{ "topic": { id: { $eq: "..." } } }
Thanks for the reply, but I think it does not solve my issue…
Please have a look on these images, I’m trying to do a search for content in builder.io search
As you can see if I search for Maxi on previewDescription it does not returns results.
Thanks
Hello @Shintaro ,
We were able to verify that this could be a potential bug in our SDK, and we have escalated it internally to our engineering team for further investigation and final resolution.
We will let you know when it is fixed.
If it helps you can try the below query, which seems to work when using multiple search fields
Note: Update [builder-model-id] and [your-builder-api-key] with your own
https://cdn.builder.io/api/v3/data?limit=25&collection=content&query.published.$ne=archived&query.$or[0].name.$regex=%28%3Fi%29Maxi&query.$or[1].data.param1.$regex=%28%3Fi%29Maxi&query.$or[2].data.param2.$regex=%28%3Fi%29Maxi&query.modelId=[builder-model-id]&query.ownerId=[your-builder-api-key]&cachebust=true&offset=0&noTraverse=true&__db=1&weakTarget=true&sort.priority=1&omit=data.blocks,data.jsCode,data.tsCode,data.cssCode&apiKey=[your-builder-api-key]