First, the all attention from previous posts above regarding JSON-Path is about recommendation, which especially flies for any newly introduced API. It is surely understood legacy APIs already in place have the original filter pattern, and are yet to support.
Then, there is a reason why multiple values can be passed only in the case of strict equality: it is not meaningful for other operators (e.g. attr>val1,val2 is basically same as attr>val where val is min(val1,val2)).
Original Message:
Sent: Oct 11, 2023 02:57
From: Piotr Ledwoń
Subject: What is the expected behavior of a filter when AND is mixed with OR?
Thanks, your answers clarified most of the issues.
I understand that jsonPath might be better for writing queries, but I am writing a parser for the query string. One thing still is unclear to me. You wrote:
"Multiple values can be passed only in the case of strict equality (=). In this case, the logical OR operation is performed over the list of comma-separated values.".
I understand it like this: attr=val1,val2 is OK, attr>val1,val2 is not. However, what about attr=value1&attr=value2? It is stated in TMF630 4.4 that it should result in oring, so unless it will be changed in later revisions, this should also be supported. Can I mix it with other conditions? Can I just assume, that whenever it appears within one AND condition, it just collapses to OR, like in the example below?
E.g. attr1=val1&attr2=val2&attr1=val3;attr4=val4 => attr1=val1,val3&attr2=val2;attr4=val4
------------------------------
Piotr Ledwoń
Suntech S.A.
Original Message:
Sent: Oct 11, 2023 01:44
From: Christophe MICHEL
Subject: What is the expected behavior of a filter when AND is mixed with OR?
Echoing Vance on top of my previous post:
In addition to the below examples, each filter query can also support JSON Path as 'filter' selector, e.g. "?filter=childResource[?(@.attribute==value)]", to apply for multiple occurences matching childResource.attribute==value.
Example (same as previous):
catalog/item?filter=size==90,100&price<10;size==110&price>100 (non encoded)
is similar to JSON Path:
catalog/item?filter=$[?((@.size==90||@.size==100)&&@.price<10)],$[?(@.size==110&&@.price>100)]
which is indeed much more flexible approach.
------------------------------
Christophe MICHEL
Amdocs Management Limited
Original Message:
Sent: Oct 11, 2023 01:34
From: Vance Shipley
Subject: What is the expected behavior of a filter when AND is mixed with OR?
Complex queries should be done using JSONPath syntax as described in TMF630 Part 6 JSON Path extension. This provides a clear syntax for arbitrarily complicated queries.
Note that the IETF Working Group on JSON Path recently submitted a final draft IETF standard to IESG for Publication as an RFC. The next version of TMF630 Part 6 should be refactored to align and reference with this standard, so we have very clear guidance.
------------------------------
Vance Shipley
SigScale
Original Message:
Sent: Oct 10, 2023 10:13
From: Piotr Ledwoń
Subject: What is the expected behavior of a filter when AND is mixed with OR?
Hello,
I have a problem with understanding filter behavior. It is shown in TMF630 part 1 (also in part 6 in the context of ORing jsonPath filters) that two operations are supported:
- AND, e.g. attr1=val1&attr2=val2
- OR, e.g. attr1=val1;attr2=val2
If the expression involves only two attributes or only one kind or logical operation, it is simple to deduce the outcome. However, when we mix AND with OR, what is the correct behavior? Lets take for example the following expression:
att1=val1;att2=val2&attr1=val3
If we assume that AND has higher precedence then it should be evaluated first. Is that correct? If it is, it means that it is impossible to create a condition in the following format: (con1 OR con2) AND (con3 OR con4).
And what if we exchange att1 with att2, like this:
att2=val2;att1=val1&attr1=val3
TMF630 states that the same attribute on both sides of AND results in oring. Does that mean that the result of changed expression is the same as att2=val2;att1=val1,val3?
Thank you in advance for the answer
Best regards
------------------------------
Piotr Ledwoń
Suntech S.A.
------------------------------