Using "OR" and "AND" operators together in advanced Alma searches
- Product: Alma
Description
Below is an explanation of the Boolean mathematics used in Alma's advanced searching, specifically when it comes to using the OR operator in conjunction with the AND operator.
Resolution
In Boolean mathematics:
“AND” is Multiplication (*)
“OR” is Plus (+)
Each condition (row) in the advanced search returns ‘0’ or ‘1’ depending on non-match / match.
Boolean mathematics rules:
1 = true
0 = false
1 AND 1 = 1 * 1 = 1
1 AND 0 = 1 * 0 = 0
0 AND 0 = 0 * 0 = 0
1 OR 1 = 1 + 1 = 1
1 OR 0 = 1 + 0 = 1
0 OR 0 = 0 + 0 = 0
So, currently all consecutive ANDs are grouped together similar to the multiplication rule which is calculated before addition (plus sign) – example:
If we would do the following in the advanced search:
A AND B AND C OR D OR E OR F AND G AND H
This is equivalent to:
A* B * C + D + E + F * G * H
And this will be calculated as:
(A* B * C) + (D) + (E) + (F * G * H)
This is how Alma advanced search logic works currently.
If for example you wanted:
A * B * ( C + D + E + F + … )
This can be simplified to:
( A * B * C ) + ( A * B * D ) + ( A * B * E ) + ( A * B * F ) + ………….
As follows:
![or operator.png](https://knowledge.exlibrisgroup.com/@api/deki/files/60976/or_operator.png?revision=1&size=bestfit&width=1233&height=899)
Additional Information
Additional information is also available on Advanced Search Logic in the New UI.
- Article last edited: 01-June-2018