SearchFilter on relation / nested attribute
See original GitHub issueI’m trying to filter on a relation property, and following the docs I added an annotation on the property:
/**
* @Groups({"campaign:get", "campaign:post"})
*
* @ApiFilter(SearchFilter::class, properties={"product.name": "ipartial"})
*
* @ORM\ManyToOne(targetEntity="App\Entity\product", inversedBy="campaigns")
* @ORM\JoinColumn(nullable=false)
*/
private $product;
Then, acessing the resource at {{url}}/api/campaigns/?product.name=CAM return all resources, including those that do not match the search.
Am I missing anything else in order to enable the filter?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Api platform aliasing filters for nested resources - Stack Overflow
I'm currently using API Platform and its default SearchFilter and it works as intended. However, filtering on ...
Read more >Filter on (nested) relationship attribute? - JSON API
Another I'm wondering is how to filter on nested relationships. Image the author has a nationality relationship with a alpha2-code attribute ...
Read more >How to Filter Results on Deeply Nested fields in Strapi
The ?filters parameter offers the ability to filter results. [authors] is a relation field in the Book collection type.
Read more >Working with Advanced Search Filter Options - Reltio
HCP has nested attributes identifiers, and a search returns 5 HCP. Out of these 5 HCP, only one has two identifiers. If the...
Read more >Active Directory user filter does not search nested groups
Cause. Crowd uses basic LDAP syntax rules for searching. By default, any searches with memberOf will only check direct attributes, so AD will ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@soyuka the problem was appending a slash and getting a 301 redirect:
I only figured this out thanks to your tip about using the Hydra serialization. It looks like with the redirect, the dot get translated to an underscore somewhere:
While this is definitely a bug, this is probably not related to Api Platform.
Indeed, it’s how PHP processes the query parameters. There’s nothing we could do about it if the original information is lost.