# Filter collection entries by collection link

**URL:** <https://discourse.getcockpit.com/t/filter-collection-entries-by-collection-link/262>\
**Category:** Support\
**Created:** [September 12, 2018, 4:25pm UTC](https://discourse.getcockpit.com/t/filter-collection-entries-by-collection-link/262 "2018-09-12T16:25:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jb-storms-media](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@jb-storms-media](https://discourse.getcockpit.com/u/jb-storms-media)\
**Post date:** [September 12, 2018, 4:25pm UTC](https://discourse.getcockpit.com/t/filter-collection-entries-by-collection-link/262/1 "2018-09-12T16:25:09Z")

</div>

Hey

does anyone know how to filter collections / collection-entries by a collection link field (that is assigned to this collection)?

No matter how we try, we always get an server error, get redirected back to collection entry-overview or just get no results.

Simply filtering by “title” (for example) instead works pretty well:  
So if our collection has the field “title” we can do:

`?q={"page":1,"filter":{"title":"abc"},"sort":{"_created":-1},"limit":20}`

and we get the entries that have “abc” within the title field as an result.

But when we try to filter by the collection-link field (the collection link field is called “categories”)) :

`{"page":1,"filter":{"categories" : {"display" : "abc"}},"sort":{"_created":-1},"limit":20}`

`{"page":1,"filter":{"categories.display" : "abc"},"sort":{"_created":-1},"limit":20}`

(I also tried “categories.link” … also no result)

we wont get any result at all.

We tried dozens of filter query strings but none brought desired results.

* * *

Perhaps there is even a better way (other then collection-links) of implementing a blog site that has categories for the posts/entries and should be filter/searchable by those categories?

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [September 24, 2018, 7:16pm UTC](https://discourse.getcockpit.com/t/filter-collection-entries-by-collection-link/262/2 "2018-09-24T19:16:57Z")

</div>

get request:  
`https://url/to/cockpit/api/collections/get/test?token=xxtokenxx&filter[link.display]=test`

post request:  
`{"filter":{"link.display":"test"}}`

Avoid whitespaces and linebreaks in json bodies.

This should work. If not, have a look at

> [@Filtering on a collectionlink](https://discourse.getcockpit.com/t/filtering-on-a-collectionlink/197):
>
> Hi, How to filter on a collection link? I tried: { “filter”: { “categories”: { “$elemMatch”: { “name”: “images” } } }, “populate”: 1 } { “filter”: { “categories”: { “name”: “images” } }, “populate”: 1 } { “filter”: { “categories”: { “\_id”: “5a9506efec401doc1908157538” } }, “populate”: 1 } But without any results I get: { “error”: true, “message”: “Condition not valid … Use name for custom operations” } as a reply Thanks in advance
