Hello !
I would like to know if it was possible to use the GraphQl API to query multiple documents using a custom field the same way I query multiple documents with id_in ?
This is the equivalent of what I want to achieve with the rest API: q=[[any(my.employee.job-title,["Developer","Designer"])]]
Hello Raoul, welcome to the Prismic community forum!
Yes, this is possible. You do this by using the FullText search. The syntax is different, because the id_in argument just receives a string or array as a variable.
First, you need to specify the language of the documents you’re going to be querying in.
Hello Paulina, thank you for your answer !
I’m looking to search on a specific field with multiple search terms.
The problem with where:{title_fulltext:"apple banana"} is that my title field must have apple AND banana but I need to request the documents where title is apple OR banana.
Is there a feature request associated with this? We really need the ability to query with a list of values-- there are multiple posts here that include this as an aspect. And/or support for filtering with basic boolean logic.
Like the original poster, I need an OR operation and it appears that the full text solution presented is limited to AND, right? (In which case maybe it shouldn't be tagged as "Solution". ;-) )
My current need is to fetch all documents with a key text field that matches any value in a list. Something like:
allFoos(where:{bar: {_in: ["a", "b", "c"]}})
Previously I've needed the inverse, all documents that do NOT match the items in a list. Something like:
allFoos(where:{bar: {_not_in: ["a", "b", "c"]}})
In this latter case (not in the list), it wasn't too inefficient to just query for all documents and filter in the client. In the present case, querying all and then filtering or executing multiple queries is much more costly.
At the moment there is still no possibility of using an OR operator in the Fultext search. The most viable solution remains the one recommended by Levi in the original post: "...run two separate queries and combine the results".
I have removed the Solution tag from the Query documents with multiple custom field values post so that it is not confusing for someone else looking for a similar solution. Thanks for the Feedback
Thanks, Paulina. Is there an open feature request associated with the need for an OR search in some capacity? Either extending the existing full-text search, or better yet, as part of extending the logic permitted in 'where' clauses (w/ support for OR, AND, NOT, and in-list / not-in-list operators)?
I'm finding we are needing this capability quite a lot-- and querying all records then filtering in our client or executing multiple queries (well more than just two, potentially) are very inefficient-- especially as we begin to scale our system.
Thanks for the feedback and for sharing your use case @jeremy2!
I understand why creating these queries would be an advantage when developing projects with GraphQL. At the moment, the Feature Request is already registered on our Product board. If news about this feature is added to graphql arguments, an announcement will be made in the original thread of the Request.
1 Like
Pau
closed , flag & select 'Something Else' to reopen.
19