Using Boolean Operators in Text Searches

When searching text fields with either the q or bq parameter, you can use the Boolean operators + (AND), | (OR), and - (NOT). These shortcuts only work for text searches. To create Boolean queries that search uint and literal fields, you need to use the Boolean query syntax described in Constructing Boolean Search Queries.

If you separate search terms with + or a space, ASN Search matches items that contain all of the specified search terms—they are ANDed together. You can use the | (OR) operator to separate terms when you want to match items that contain either the preceding term(s) or the following term(s).

To exclude items that contain a particular term from the search results, prefix the term with the - (NOT) operator. For example, to search for all of the items that don't contain the term read in the default search field, you would specify: search?q=-read. The NOT operator only applies to individual terms. Searching for search?q=-read+write retrieves all items that do not contain the term read, but do contain the term write.

For example, when searching the ASN dataset:

../search?q=read|write

matches items that contain either read or write in the default search field.

search?bq=description:'read write|spell'

matches items that contain both the terms read and write or the term spell in the description field.

../search?bq=description:'read|write|spell'

matches items that contain either read, write, or spell in the description field.

../search?bq=description:'"writes cursive"|"reads cursive"'

matches items that contain either the phrase writes cursive or the phrase reads cursive in the description field.

../search?bq='description:-read+write|spell'

matches items whose descriptions do not contain read, but do contain either write or spell.

You can also use the Boolean operators when constructing queries using the full Boolean query syntax. For example,

../search?bq=(and description:'Biology|Chemistry' (not education_level:'8'))

matches items that contain either Biology or Chemistry, but not in grade 8.

For more information about the Boolean query syntax, see Constructing Boolean Search Queries.