OR filter on query

Hello there,

I’m trying to implement a simple search function into our app that retrieves its content from Dato.
We might need a more powerful way of searching later, but to begin with I want to filter a title and content field based on a given search term and return all entries that match the keyword on ANY of them.

I tried following this example:
https://www.datocms.com/docs/content-delivery-api/filtering

and build the following filter:
{OR: {shoeDescription: {matches: {pattern: “Nike”, caseSensitive: “false”}}, entryTitle: {matches: {pattern: “Nike”, caseSensitive: “false”}}}}

which in my understanding should return all entries that match “Nike” on the “entryTitle” AND/OR “shoeDescription”. But this isn’t the case. It returns 0 entries on my tests (only 1 available entry, which has only “nike” in the entryTitle but nothing in the shoeDescription).

If I add “nike” to the “shoeDescription” as well, the entry gets returned. How do I specifiy, that only one of the OR-filters need to hit, to end in a result?

Thanks a lot :pray:

Florian,

Hello @heat-mvmnt and welcome to Community! :slight_smile:

I think there’s a small error in your query, it should be something like:

{
  OR: [
    { shoeDescription: { matches: { pattern: “Nike”, caseSensitive: “false” } } },
    { entryTitle: { matches: { pattern: “Nike”, caseSensitive: “false” } } }
  ]
}

what do you think?

If you have created that with the API explorer’s interface, unfortunately we know that it’s a missing feature in GraphiQL: https://github.com/OneGraph/graphiql-explorer/issues/32

Hey @mat_jack1,

thanks for your answer & your welcome – an array input makes totally sense and seems to be working.
Correct, I have created the query via the API explorer interface – good to know for future explorations.

Have a nice day :slight_smile: