When a list of taxonomies is passed into our search engine it returns all records that have at least one of those taxonomies. In other words, given taxonomies A, B, and C it will return all records that have A or B or C.
Our query engine now allows us to pass in more advanced logic, including this scenario:
Return records with (A AND B) OR (A AND )
Eventually, these kinds of advanced queries will have controls in the user interface. For now they have to be manually created.
<aside> <img src="/icons/thumbs-up_pink.svg" alt="/icons/thumbs-up_pink.svg" width="40px" />
Our team is here for training and support if you have a use-case for advanced queries. Don’t feel like it’s just you and this doc 🙂
</aside>
A basic query for Veteran Benefits Assistance, Veteran, and Active Duty Military looks like this:
?query=FT-1000.9000,YN-9000,YN-0500
An advanced query for Benefits Assistance for Veterans OR Benefits Assistance for Active Duty would look like this:
?query={
"OR": [
{"AND": ["FT-1000.9000", "YN-9000"]},
{"AND": ["FT-1000.9000", "YN-0500"]}
]
}
We could remix the logic if it’s more intuitive:
?query={
"AND": [
"FT-1000.9000",
{"OR": ["FT-1000.9000", "YN-0500"]}
]
}
Both are supported; feel free to form queries the way that makes the most sense to you.
We could also modify that to return broader results for just Active Duty Military:
?query={
"OR": [
{"AND": ["FT-1000.9000", "YN-9000"]},
"YN-0500"
]
}
Before the above structures are actually put into a URL for an advanced search, they must strip all white space and be encoded using an online tool like https://www.urlencoder.org/. The results might look a little strange, but that’s just how URLs work.
Our examples above look like this after being condensed and encoded:
Example 1
?query=FT-1000.9000%2CYN-9000%2CYN-0500
Example 2.a
?query=%7B%22OR%22%3A%5B%7B%22AND%22%3A%5B%22FT-1000.9000%22%2C%22YN-9000%22%5D%7D%2C%7B%22AND%22%3A%5B%22FT-1000.9000%22%2C%22YN-0500%22%5D%7D%5D%7D
Example 2.b
%3Fquery%3D%7B%22AND%22%3A%5B%22FT-1000.9000%22%2C%7B%22OR%22%3A%5B%22FT-1000.9000%22%2C%22YN-0500%22%5D%7D%5D%7D