Re: [Dhis2-devs-core] Change from OR to AND in object filter queries

2015-06-03 Thread John Mukulu
Hey Morten,
Why [] in the filter, why not just plain

?filter=id:in:1,2,3
?filter=name:in:John,Marie

Concerning or with two different operators, you could probably introduce OR
filter that overrides default AND logic, something like these:

*type=int OR numberType=number*
?filter=type:eq:intfilterOr=numberType:eq:number

*type=int AND numberType=number*
?filter=type:eq:intfilter=numberType:eq:number

*type=int OR numberType in (number,int)*
?filter=type:eq:intfilterOr=numberType:in:number,int

*type=int AND numberType in (number,int)*
?filter=type:eq:intfilter=numberType:in:number,int


On Wed, Jun 3, 2015 at 12:14 PM, Morten Olav Hansen morte...@gmail.com
wrote:

 Hi

 The [] syntax for now is only for the IN operator (which supports a list
 of values), I could see it working for like etc also, but then what would
 we do if we want an OR but with two different operators?

 --
 Morten

 On Wed, Jun 3, 2015 at 4:07 PM, Mark Polak mar...@ifi.uio.no wrote:

  Hey All,

  You are right Jan. It does an AND for different fields. But if you try
 to filter on the same field it will do an OR.

  This behaviour is a bit confusing, that one is OR and the other is AND.
 For that reason alone i like the new syntax of introducing a different OR
 for the same fields.

  ?filter=id:in[1,2]

  One thing that comes to mind, how would i use a LIKE when doing an OR?
  ( i don't have an immediate need for this i think though :))

  would i be able to do something like

  ?filter=name:like[John,Marie]

  Regards,

  Mark

  On 3 Jun 2015, at 10:08, Jan Henrik Øverland 
 janhenrik.overl...@gmail.com wrote:


 https://apps.dhis2.org/demo/api/dataElements.json?paging=falsefilter=dataElementGroups.id:eq:qfxEYY9xAl6filter=name:like:dose




 --
 Mailing list: https://launchpad.net/~dhis2-devs-core
 Post to : dhis2-devs-core@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs-core
 More help   : https://help.launchpad.net/ListHelp




-- 
*Full name: *John Francis Mukulu
*Mobile Phone:* +255717154006
*Website:* http://mukulu.tk/
*Social Coding:* http://github.com/mukulu https://bitbucket.org/mukulu
*Open source developer*
-- 
Mailing list: https://launchpad.net/~dhis2-devs-core
Post to : dhis2-devs-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs-core
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs-core] Change from OR to AND in object filter queries

2015-06-03 Thread Jan Henrik Øverland
Makes sense. But it sort of works like that already? E.g:

1)
https://apps.dhis2.org/demo/api/dataElements.json?paging=falsefilter=dataElementGroups.id:eq:qfxEYY9xAl6
returns all members of the ANC group (11x)

2)
https://apps.dhis2.org/demo/api/dataElements.json?paging=falsefilter=name:like:dose
returns all data elements with a name containing dose (27x)

3)
https://apps.dhis2.org/demo/api/dataElements.json?paging=falsefilter=dataElementGroups.id:eq:qfxEYY9xAl6filter=name:like:dose
returns the data elements that are in query 1 AND query 2 (only 4x)

On Wed, Jun 3, 2015 at 6:46 AM, Morten Olav Hansen morte...@gmail.com
wrote:

 Hi everyone

 One of my tasks for 2.20 is to better handle AND/OR in object filter
 queries. As part of this, we are considering changing the default from OR
 to AND, which means that something like this:

 ?filter=id:eq:1filter=id:eq:2

 Will not work anymore, you will have to use:

 ?filter=id:in:[1,2]

 I will backport this, so it works the same in 2.19 (so we don't have
 different semantics in 2.19 vs 2.20), and in 2.20 there will probably be
 introduced some kind of OR operator also (can still be useful for some
 cases)

 Doing this, also means that you can do proper filtering on multiple
 properties, e.g.:

 /api/dataElements?fields=*filter=domainType:eq:TRACKERfilter=numberType:eq:int

 Which will give the results where domain is TRACKER -AND- number type is
 int.

 If we all agree on this, I will also send out a notice on the mailing
 lists to notify external app developers.

 --
 Morten

 --
 Mailing list: https://launchpad.net/~dhis2-devs-core
 Post to : dhis2-devs-core@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs-core
 More help   : https://help.launchpad.net/ListHelp


-- 
Mailing list: https://launchpad.net/~dhis2-devs-core
Post to : dhis2-devs-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs-core
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs-core] Change from OR to AND in object filter queries

2015-06-03 Thread Morten Olav Hansen
Hi

The [] syntax for now is only for the IN operator (which supports a list of
values), I could see it working for like etc also, but then what would we
do if we want an OR but with two different operators?

--
Morten

On Wed, Jun 3, 2015 at 4:07 PM, Mark Polak mar...@ifi.uio.no wrote:

  Hey All,

  You are right Jan. It does an AND for different fields. But if you try
 to filter on the same field it will do an OR.

  This behaviour is a bit confusing, that one is OR and the other is AND.
 For that reason alone i like the new syntax of introducing a different OR
 for the same fields.

  ?filter=id:in[1,2]

  One thing that comes to mind, how would i use a LIKE when doing an OR?
  ( i don't have an immediate need for this i think though :))

  would i be able to do something like

  ?filter=name:like[John,Marie]

  Regards,

  Mark

  On 3 Jun 2015, at 10:08, Jan Henrik Øverland 
 janhenrik.overl...@gmail.com wrote:


 https://apps.dhis2.org/demo/api/dataElements.json?paging=falsefilter=dataElementGroups.id:eq:qfxEYY9xAl6filter=name:like:dose



-- 
Mailing list: https://launchpad.net/~dhis2-devs-core
Post to : dhis2-devs-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs-core
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs-core] Change from OR to AND in object filter queries

2015-06-03 Thread Mark Polak
Hey All,

You are right Jan. It does an AND for different fields. But if you try to 
filter on the same field it will do an OR.

This behaviour is a bit confusing, that one is OR and the other is AND. For 
that reason alone i like the new syntax of introducing a different OR for the 
same fields.

?filter=id:in[1,2]

One thing that comes to mind, how would i use a LIKE when doing an OR?  ( i 
don't have an immediate need for this i think though :))

would i be able to do something like

?filter=name:like[John,Marie]

Regards,

Mark

On 3 Jun 2015, at 10:08, Jan Henrik Øverland 
janhenrik.overl...@gmail.commailto:janhenrik.overl...@gmail.com wrote:

https://apps.dhis2.org/demo/api/dataElements.json?paging=falsefilter=dataElementGroups.id:eq:qfxEYY9xAl6filter=name:like:dose

-- 
Mailing list: https://launchpad.net/~dhis2-devs-core
Post to : dhis2-devs-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs-core
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs-core] Change from OR to AND in object filter queries

2015-06-03 Thread Lars Helge Øverland
Yes agree.

On Wed, Jun 3, 2015 at 10:25 AM, Morten Olav Hansen morte...@gmail.com
wrote:

 Actually no, thats a bug ;) this is why I have a blueprint for this in
 2.20, its a bit messy when you are combining an optimized path with a
 non-optimized path... in that case, the like will be run through the
 optimized criteria, and that result is given to the in-memory filter.. if
 you try with two optimized paths, you will see that its actually an OR

 But yes, I think this really makes sense.. I have it working here locally
 now, just need to update the in-memory filter also.. and I will commit this
 tomorrow..

 Do we all agree that it should be backported to 2.19?

 --
 Morten

 On Wed, Jun 3, 2015 at 3:08 PM, Jan Henrik Øverland 
 janhenrik.overl...@gmail.com wrote:

 Makes sense. But it sort of works like that already? E.g:

 1)
 https://apps.dhis2.org/demo/api/dataElements.json?paging=falsefilter=dataElementGroups.id:eq:qfxEYY9xAl6
 returns all members of the ANC group (11x)

 2)
 https://apps.dhis2.org/demo/api/dataElements.json?paging=falsefilter=name:like:dose
 returns all data elements with a name containing dose (27x)

 3)
 https://apps.dhis2.org/demo/api/dataElements.json?paging=falsefilter=dataElementGroups.id:eq:qfxEYY9xAl6filter=name:like:dose
 returns the data elements that are in query 1 AND query 2 (only 4x)

 On Wed, Jun 3, 2015 at 6:46 AM, Morten Olav Hansen morte...@gmail.com
 wrote:

 Hi everyone

 One of my tasks for 2.20 is to better handle AND/OR in object filter
 queries. As part of this, we are considering changing the default from OR
 to AND, which means that something like this:

 ?filter=id:eq:1filter=id:eq:2

 Will not work anymore, you will have to use:

 ?filter=id:in:[1,2]

 I will backport this, so it works the same in 2.19 (so we don't have
 different semantics in 2.19 vs 2.20), and in 2.20 there will probably be
 introduced some kind of OR operator also (can still be useful for some
 cases)

 Doing this, also means that you can do proper filtering on multiple
 properties, e.g.:

 /api/dataElements?fields=*filter=domainType:eq:TRACKERfilter=numberType:eq:int

 Which will give the results where domain is TRACKER -AND- number type is
 int.

 If we all agree on this, I will also send out a notice on the mailing
 lists to notify external app developers.

 --
 Morten

 --
 Mailing list: https://launchpad.net/~dhis2-devs-core
 Post to : dhis2-devs-core@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs-core
 More help   : https://help.launchpad.net/ListHelp




 --
 Mailing list: https://launchpad.net/~dhis2-devs-core
 Post to : dhis2-devs-core@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs-core
 More help   : https://help.launchpad.net/ListHelp


-- 
Mailing list: https://launchpad.net/~dhis2-devs-core
Post to : dhis2-devs-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs-core
More help   : https://help.launchpad.net/ListHelp