Is it possible to make a API query mixing AND and OR joins?


The idea is to make an API query that meets the following condition, for example:

1- property 1 should meet a string STRING
2- property 2 should include the value 1956 or 1978

That is, list all the item with STRING that has the value 1956 or 1978. The rest of items with STRING should be excluded.

As example, there are 10 items with STRING, two items with value 1956 and one item with value 1978. Then the resulting list should include only 3 items.

I use the [joiner] AND and OR in the query but it does not work:


is it possible?


What results are you getting instead?

The way AND and OR work in SQL is that AND binds more tightly, so as written your query is

("property 1 contains STRING" AND "property 2 is 1956") OR "property 2 is 1978".

From what you described and the query you ran, I’d expect you to get the 2 items that are STRING and 1956, plus all items that have 1978 for property 2, regardless of if they have STRING for property 1. Is that what you’re getting?


Following the written query, what I want to get is:

("property 1 contains STRING" ) AND ("property 2 is 1956" OR "property 2 is 1978").

My target is to be able to include a range of dates in the second part of the query:

("property 1 contains STRING" ) AND ("property 2 is 1956" OR "property 2 is 1978" OR "property 2 is 1980" OR "property 2 is 1982" OR ...).


Replicating the AND on both sides of the OR should work, like “contains STRING” AND “is 1956” OR “contains STRING” AND “is 1978”, but that’s going to get a little repetitive on bigger numbers of options.