xiaohutai / jsonapi

[Bolt Extension] JSON API for Bolt CMS
https://market.bolt.cm/view/bolt/jsonapi
MIT License
55 stars 18 forks source link

So what should a filtered request look like? #14

Closed ghost closed 7 years ago

ghost commented 8 years ago

I currently find myself in a situation where I can use a secondary filter on my json request so I have 2 overlapping taxonomies which I want to use to filter my request. Is this possible and what should it look like?

this is my guess: /json/{ct}&filter["fieldname"]=constraints&filter["fieldname2"]=constraints

jasperjorna commented 8 years ago

I got a filtered request like this working: http://foo.dev/json/projects?filter[expertise]=bar

However I'm unable to get filtered results when I try to filter with a search query: http://foo.dev/json/search?q=test&filter[id]=7

ghost commented 8 years ago

so does: http://foo.dev/json/projects?filter[foo]=bar?filter[lorum]=ipsum also work? or will it become like: http://foo.dev/json/projects?filter[foo]=bar&filter[lorum]=ipsum

ghost commented 8 years ago

@Twiebie I did some reading in the jsonapi specification that this extension follows and I found this: http://jsonapi.org/recommendations/#filtering I was hoping to get some answers if this filtering method will work for taxonomies.

xiaohutai commented 7 years ago

Yes, you are correct. It should work for taxonomies.

In a query string, you do it like this:

?name1=value1&name2=value2&name3=value3

and so on, so one ? and the rest start with &.

It is not possible to use a search query with filters. You could attempt to use the contains on a body field and then use filters though, but that's not really a search query.