# Query documents by slice data

**URL:** <https://community.prismic.io/t/query-documents-by-slice-data/660>\
**Category:** Developing with Prismic\
**Created:** [June 3, 2020, 6:23pm UTC](https://community.prismic.io/t/query-documents-by-slice-data/660 "2020-06-03T18:23:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![levijesica](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/levijesica/32/233_2.png) [@levijesica](https://community.prismic.io/u/levijesica)\
**Post date:** [June 3, 2020, 6:23pm UTC](https://community.prismic.io/t/query-documents-by-slice-data/660/1 "2020-06-03T18:23:39Z")

</div>

I have a blog post that has slice that could have multiple relations with another type. So basically I have a blog post that can have multiple categories. I need to filter all posts that contains a categoryid. The category id is on teh vody of the result data. I didn't find any docs that stays how to query by slice data. Is this even possible? If it's not, what would be the best way to model the data in order to have a post with multiple categories and be able to search a post by any of the categories ?

Thanks!

---

<div class="post-metadata">

**Author:** ![Levi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/levi/32/24_2.png) [@Levi](https://community.prismic.io/u/Levi)\
**Post date:** [June 4, 2020, 8:55am UTC](https://community.prismic.io/t/query-documents-by-slice-data/660/3 "2020-06-04T08:55:54Z")

</div>

Hi @levijesica, unfortunately it isn’t possible to query by a field inside of a Slice. In order to do what you want to do, you can use a Content Relationship field inside of a Group field. This you can query by and will allow you to select multiple categories for each post.

---

<div class="post-metadata">

**Author:** ![Levi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/levi/32/24_2.png) [@Levi](https://community.prismic.io/u/Levi)\
**Post date:** [September 21, 2020, 8:48am UTC](https://community.prismic.io/t/query-documents-by-slice-data/660/5 "2020-09-21T08:48:44Z")

</div>

closed on September 21, 2020, 8:48am UTC, flag & select 'Something Else' to reopen.



---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [December 9, 2021, 12:12pm UTC](https://community.prismic.io/t/query-documents-by-slice-data/660/6 "2021-12-09T12:12:35Z")

</div>

Opened on December 9, 2021, 12:12pm UTC


