Query 'Key Text' fields inside a slice's repeatable group and return the page

Hi

I'm using the react starter kit

I have a number of slices containing repeating groups of content.

I want to query the API and return all items based on a key text field in a slice's repeating group that matches the users entered search term.

Structure below - I want to be able to query on the repeating media_title AND the non-repeating genre_name ie: search for 'I may destroy you' OR search for 'Drama' in the one query. So I can display results with images etc.

Thanks in advance

        "data": {
            "tv_search": {
                "category": {
                    "type": "StructuredText",
                    "value": [
                        {
                            "type": "heading1",
                            "text": "TV Shows",
                            "spans": []
                        }
                    ]
                },
                "category_tile": {
                    "type": "Image",
                    "value": {
                        "main": {
                            "dimensions": {
                                "width": 227,
                                "height": 127
                            },
                            "alt": null,
                            "copyright": null,
                            "url": "https://images.prismic.io/xxx-xxx/094f9238-3b9e-488c-8ebf-9242ce0a751d_tv-shows.png?auto=compress,format"
                        },
                        "views": {}
                    }
                },
                "body": {
                    "type": "SliceZone",
                    "value": [
                        {
                            "type": "Slice",
                            "slice_type": "genre",
                            "slice_label": null,
                            "repeat": [
                                {
                                    "content_image": {
                                        "type": "Image",
                                        "value": {
                                            "main": {
                                                "dimensions": {
                                                    "width": 227,
                                                    "height": 126
                                                },
                                                "alt": null,
                                                "copyright": null,
                                                "url": "https://images.prismic.io/xxx-xxx/5ff57709-0e48-4f80-beee-f306016b2ef9_Frame+2240.png?auto=compress,format&rect=0,0,227,126&w=227&h=126"
                                            },
                                            "views": {}
                                        }
                                    },
                                    "media_title": {
                                        "type": "Text",
                                        "value": "I may destroy you"
                                    }
                                }
                            ],
                            "non-repeat": {
                                "genre_name": {
                                    "type": "StructuredText",
                                    "value": [
                                        {
                                            "type": "heading3",
                                            "text": "Drama",
                                            "spans": []
                                        }
                                    ]
                                }
                            }
                        }
                    ]
                }
            }
        }
    }

Hello @rob.brough,

Welcome to the Prismic community.

You can try and use the Fulltext search for getting results based upon the key text field. But it isn’t possible to do an OR query like this for fulltext. The only workaround I can think of would be to run two separate queries and combine the results.

Let me know if you have any doubt.

Thanks,

Priyanka

@Priyanka thanks for you help - I've used a local search tool to do the final OR part

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.