Need query example with API Parameters: "contains" filter with "or" operator

System Information
  • Strapi Version: 3.1.4
  • Operating System: Win 10
  • Database: MongoDB
  • Node Version: >=10.0.0
  • NPM Version: >=6.0.0
  • Yarn Version: -

Good day, everyone!

I was trying to test Strapi API of my old pet project (blog) in Postman.

Case example: user searches for blog articles, the entered value should be “contained” in title “or” content of articles.

I couldn’t find the query example with both “_contains” filter and “or” operator in docs. There’s an old GitHub issue about this, but no examples also.

I tried to do various combinations with “_where”, “_contains” and “or” but no luck.

Can anyone show me how to use the latter two together in query (without “qs” library, please)?

?_where[_or][0][title_contains]=test&_where[_or][1][content_contains]=test

Where title contains test OR content contains test.

5 Likes

Oh, that’s how! I was doing a tiny bit incorrect. Thank you, Sunny Son!

1 Like

Many Thanks.
By reading and rereading the doc I began to tell myself that it was not possible.
Can be add this example to the doc. It will surely help a lot of people

Since the api has updated but this post is still the first result in google here is the solution for the current version: 2023-12 Strapi v4.8.2

?filters[field][$contains]=value

So for this post example

?filters[title][$contains]=test&filters[content][$contains]=test

Can be found in the docs here: Filters, Locale, and Publication State | Strapi Documentation

1 Like