Global & Advanced Search
Relevant source files
The following files were used as context for generating this wiki page:
The Global & Advanced Search system provides a robust interface for querying genomic and bioinformatic data across various categories including genomes, features, subsystems, and protein motifs. The system is designed to handle both simple keyword searches and complex, multi-parameter queries using a structured logic-based interface.
The architecture relies on a modular widget system where GlobalSearch serves as the primary entry point for quick queries, while AdvancedSearch and specialized search widgets (e.g., SubsystemSearch) provide granular control over metadata fields. These components translate user input into Solr-compatible RQL queries that are processed by the data API.
Global Search System
The Global Search functionality is implemented in the GlobalSearch widget. it handles broad queries across the entire platform and provides filtering options to narrow results to specific data types like "sp_genes", "genomes", or "proteins".
Query Processing Logic
Before a query is submitted, it undergoes several transformations to ensure compatibility with the backend search engine (Solr). This includes replacing special characters, handling quoted phrases, and automatically quoting identifiers like FIG IDs or EC numbers.
Navigation and Filtering
The Global Search widget uses a searchFilter to determine the navigation destination. Depending on the selected filter, the system publishes a /navigate message to specific list viewers with the generated query.
| Filter Category | Target Route |
|---|---|
| Everything | /search/?<query> |
| Genomes | /view/GenomeList/?<query>#view_tab=genomes |
| Proteins | /view/ProteinList/?<query>#view_tab=proteins |
| Taxonomy | /view/TaxonList/?<query> |
| Subsystems | /view/SubsystemList/?<query> |
Sources: public/js/p3/widget/GlobalSearch.js:100-165
Advanced Search Architecture
Advanced Search is facilitated by a specialized set of widgets that allow users to build complex boolean queries. This system is primarily driven by SearchBase.js, which provides the foundation for row-based query construction.
SearchBase and Row Forms
The SearchBase widget dynamically builds a search panel based on searchable fields defined for a specific data key. It manages a collection of AdvancedSearchRowForm widgets, each representing a single search condition.
- Dynamic Rows: Users can add or remove rows, selecting specific metadata columns and operators.
- Logic Mapping: It supports
AND,OR, andNOTlogical operations between rows. - Data Types: Fields are treated differently based on their type (e.g.,
str,numeric,date).
Query Construction Flow
The system maps UI components to specific RQL operators:
- Strings: Mapped to
eq()(equals) orne()(not equal). - Numeric/Decimal: Mapped to
between(),gt()(greater than), orlt()(less than). - Dates: Converts local dates to UTC ISO strings and uses range operators.
Specialized Search Widgets
The project includes specialized search interfaces for specific data domains, inheriting from SearchBase.
Subsystem and Domain Search
- SubsystemSearch: Provides specific inputs for Pathogen Groups, Taxon Names, and Subsystem IDs. It combines these specific inputs with the advanced row-based query.
- DomainAndMotifSearch: Focuses on protein features, allowing searches by source (e.g., Pfam, InterPro) and description.
| Component | Specialized Fields | Data Key |
|---|---|---|
SubsystemSearch | Pathogen Group, Subsystem ID, Subsystem Role | subsystem |
DomainAndMotifSearch | Source, Source ID, Protein Description | protein_feature |
Sources: public/js/p3/widget/search/SubsystemSearch.js:30-80, public/js/p3/widget/search/DomainAndMotifSearch.js:30-80
Filtering and Facet Integration
The FilterContainerActionBar manages real-time filtering of result lists using facets. It allows users to toggle filters on specific metadata categories and see updated counts before applying them to the view.
Facet Logic
The action bar retrieves facets from the data API using a facet() RQL function. It supports:
- Keyword Search: Integration of a keyword textbox that updates the global filter state.
- Category Selection: Multi-select dropdowns to add or remove visible facet categories.
- Advanced Search Dialog: A button to launch a modal version of the Advanced Search interface specifically for the current list view.
Sources: public/js/p3/widget/FilterContainerActionBar.js:150-350
Conclusion
The search infrastructure provides a unified approach to data discovery, ranging from simple keyword entry in GlobalSearch to granular boolean construction in specialized widgets. By translating UI-level logic into standardized RQL queries, the system ensures consistent communication with the bioinformatic data API while offering a flexible interface for researchers.