V8-archive: Filter: support multiple filter same field

Created on 17 May 2018  Â·  8Comments  Â·  Source: directus/v8-archive

Allow multiple filter to the same column.

Country = 'Japan' OR Country = 'Germany'

enhancement

Most helpful comment

furthermore, this would be very usefull for between filters:

filter[id][between]=1,15&filter[id][between]=30,45

to get the ranges 1-15 and 30-45

All 8 comments

Isn't this already possible with the logical or thingy?

?filter[country][eq]=Japan&filter[country][logical]=or&filter[country][eq]=Germany

And even if that's not the way to do this, how about in? ?filter[country][in]=Japan,Germany

@WellingGuzman thoughts?

No, that's broken. The problem we are having here is that all fields are an "object" with all the keys being a field name, in that case if you create two filter using the same field, it will remove the first one.

The example below:

filter[country][eq]=Japan&filter[country][logical]=or&filter[country][eq]=Germany

Will end up being:

filter[country][eq]=Germany&filter[country][logical]=or

furthermore, this would be very usefull for between filters:

filter[id][between]=1,15&filter[id][between]=30,45

to get the ranges 1-15 and 30-45

At the moment it supports multiple filter for te same field. The problem it could be a bit ugly, just for the sake of the "array in url" thing:

filter[id][][between]=1,15&filter[id][][between]=30,45

Although to include ranges between 1 and 15, and 30 and 45. it should be an or.

Here where it gets ugly:

filter[id][0][between]=1,15&filter[id][0][logical]=or&filter[id][1][between]=30,45

This was implemented by https://github.com/directus/api/commit/b37f5bbb173849bf8383876185af48e26612f60b


I was thinking on trying to implement a parser to allow multiple fields without adding the array. In addiction to the default using array.

So it looks like this:

filter[id][between]=1,15&filter[id][between]=30,45

Instead of:

filter[id][][between]=1,15&filter[id][][between]=30,45

So @WellingGuzman — is this ticket complete/closed now? Should we open a new ticket for cleaning up the syntax?

So @WellingGuzman — is this ticket complete/closed now? Should we open a new ticket for cleaning up the syntax?

Yes @benhaynes, that would be ideal.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benhaynes picture benhaynes  Â·  4Comments

metalmarco picture metalmarco  Â·  3Comments

Varulv1997 picture Varulv1997  Â·  3Comments

cdwmhcc picture cdwmhcc  Â·  3Comments

maettyhawk picture maettyhawk  Â·  3Comments