To understand AND and OR relationship.
Let say we have posts with following category and tag:
1. Post 1 – Category : cat 1, Tag : tag 1
2. Post 2 – Category : cat 2, Tag : tag 2
3. Post 3 – Category : cat 3, Tag : tag 3
4. Post 4 – Category : cat 4, Tag : tag 1
Scenario 1 – User select cat 1 and All tag :
In OR relationship:
– All Post 1, 2, 3 and 4 will be found because it will look for posts with cat 1 and also look for posts with Tag regardless what the tag is.
In AND relationship:
– All Post 1, 2, 3 and 4 will be found because will look for post with cat 1 AND Tag (regardless what the tag is)
Scenario 2 – User Select cat 1 and tag 2:
In OR relationship:
– Post 1 and 2 will be found, because there are post with cat 1 and also (OR) have post with tag 2.
In AND relationship:
– No post will be found, because there are no post that have cat 1 AND tag 2
Scenario 3 – User Select cat 4 and tag 1:
In OR relationship:
– Post 1 and 4 will be found because there are post with cat 4 (Post 4) and also have post with tag 1 (Post 1 and Post 4)
In AND relationship:
– Post 4 will be found because on this post have cat 4 AND tag 1.
From the example above, OR will look for all query term as long as the Category and Tag present in the query.
Eg: it will look for the post that have A and look for the post that have B.
And for AND, it will only look for posts that have Category AND Tag that match the query terms.
Eg: it will look for the post that have A AND B only.
So, as you can see AND relationship will more accurate result.
AS for the operator, you can only use AND when the input type is checkbox. Otherwise IN is enough.
If you cannot get result from AND relationship, then probably your search input doesn’t match the posts. See Scenario 2. You can try Scenario 1 first to see any result found.