Hi, I have read the REST API document and I would like to use predicate query to fetch document which has certain string in a field in Slice repeatable zone.
Following image is my slice. The field type is Key Text and the field api id is
Editor might add multiple "tag" and I want to check if any of their value match a string typed by end user.
My custom type is
post, and the Slice id is
Here's my current query way:
], lang: 'en'
It didn't work even I add a tag with text "Activities" in the document. How can I fix it?
Thanks for reaching out.
Please clarify if you would like to return only the slice that matches the query or the whole document?
Note: I really recommend you to try to use the API browser when testing such queries as it has fewer variables.
Looking forward to your reply,
Hi @Fares ,
I would like to return the whole document that matches the
fulltext query. Just like what other query predicate gets from their response.
I have tried using the API browser before. However I don't know how to correctly write a query to search documents in certain language with API browser. The query text always turns red wherever I put the
Would you also give an example for it? Since I can't find any using lang filer to do with API browser example in your documents.
To query a particular locale you need to pass the language as a query string in the URL as what is described in the documentation
Can you share with me your repository name to prepare and share a query example with you.
Our repository name is furbo-prismic-dev.
I have successfully searched my post document with language query string.
However, I can't get any document when I tried to search key text field
tag in my tags slice
Followings are part of the result I searched post document by title filed.
The image shows tags slice content in the document. It has three key text in the slice
I'm still investigating, and I'm not sure that your query [fulltext(my.post.tags.tag, "furbo")] matches
the same data structure
I will check with my team and get back to you,
I have checked with my team, and it turns out that it is impossible to query slice items fields with a fulltext predicate and few other predicates.
But I'm curious about the functional use case of having a tags slice as this doesn't seem to be a standard implementation.
Looking forward to your reply,
Yes the data structure of the screenshot you shared is the exact document I want to query from. By the way, could you remove or hide the sensitive information (ex. id) in it? Very thanks!
We want to do a function that users can click a tag then be redirected to the search result page to search blog post with the tag name. We would like to add many tags in the post document so we chose to create a tag slice instead of using Prismic original tagging system.
According to your answer, seems creating a tag slice is not a proper solution if querying slice items field with predicate is impossible.
Thanks for sharing this information, and I have removed the screenshot with sensitive info, and why don't you use the native tagging system or have custom-type tags for more customization where you can link to the
tags documents with content relationship fields?
Really sorry for the late reply. Thanks for your suggestion.
As we would like to do a tag function that user can click the tag and led to the search page to search with the tag name, it's ideal to use predicate querying the posts which has a tag matching the term.
I've tried creating a custom-type
tag document and added it as content relationship in my post doc. But it seemed I cannot use
fulltext predicate to query content relationship field in a document. Neither the native tagging system can be queried by
Hey @kelly_ke, you need to only specify the Custom Type and then the field:
post.tag. Or you could query the entire document, like so:
That's exactly the ideal solution. Very thanks!
We're glad it was helpful. Let us know if you need anything else.