Lint
Search-query implements various syntax validation checks (aka. linters) and prints instructive messages to inform users about potential issues. These checks help to prevent errors—an important step given that previous studies have found high error rates in search queries (Li & Rainer, 2023; Salvador-Oliván et al., 2019; Sampson & McGowan, 2006).
from search_query.parser import parse
query_string = '("digital health"[Title/Abstract]) AND ("privacy"[Title/Abstract]'
query = parse(query_string, platform="pubmed")
# Output:
# ❌ Fatal: unbalanced-parentheses (F1001)
# Unbalanced opening parenthesis
# ("digital health"[Title/Abstract]) AND ("privacy"[Title/Abstract]
# ^^^
Fatal Errors
- F0001 — tokenizing-failed
- F1001 — unbalanced-parentheses
- F1002 — unbalanced-quotes
- F1004 — invalid-token-sequence
- F1009 — empty-parentheses
- F1010 — invalid-syntax
- F1011 — too-many-operators
- F1012 — too-many-search-terms
- F2001 — wildcard-unsupported
- F2002 — wildcard-in-year
- F2003 — wildcard-right-short-length
- F2004 — wildcard-left-short-length
- F2005 — wildcard-after-special-char
- F2006 — wildcard-standalone
- F2007 — near-distance-too-large
- F2008 — isbn-format-invalid
- F2009 — doi-format-invalid
- F2010 — year-span-violation
- F2011 — search-field-unsupported
- F2012 — year-without-search-terms
- F2013 — nested-query-with-search-field
- F2014 — year-format-invalid
- F3001 — missing-root-node
- F3002 — missing-operator-nodes
- F3003 — invalid-list-reference
Errors
Warnings
- W0001 — search-field-redundant
- W0002 — search-field-extracted
- W0004 — query-structure-unnecessarily-complex
- W0005 — operator-capitalization
- W0006 — implicit-near-value
- W0007 — implicit-precedence
- W0008 — token-ambiguity
- W0009 — boolean-operator-readability
- W0010 — character-replacement
- W0011 — date-filter-in-subquery
- W0012 — implicit-operator
- W0013 — non-standard-quotes
- W0014 — journal-filter-in-subquery
- W0015 — unsupported-prefix
- W0016 — unsupported-suffix
References
Li, Z., & Rainer, A. (2023). Reproducible Searches in Systematic Reviews: An Evaluation and Guidelines. IEEE Access, 11, 84048–84060. IEEE Access. doi: 10.1109/ACCESS.2023.3299211 Salvador-Oliván, J. A., Marco-Cuenca, G., & Arquero-Avilés, R. (2019). Errors in search strategies used in systematic reviews and their effects on information retrieval. Journal of the Medical Library Association : JMLA, 107(2), 210. doi: 10.5195/jmla.2019.567 Sampson, M., & McGowan, J. (2006). Errors in search strategies were identified by type and frequency. Journal of Clinical Epidemiology, 59(10), 1057–1063. doi: 10.1016/j.jclinepi.2006.01.007