Solr
SolrImplementation
dataclass
Bases: EntityInterface, AssociationInterface, SearchInterface, GroundingInterface
Implementation of Monarch Interfaces for Solr endpoint
get_association_counts
Get list of association counts for a given entity
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity
|
str
|
The entity ID to get association counts for. |
required |
entity_category
|
Optional[str]
|
The biolink category of the entity (e.g. 'biolink:Gene'). If the entity is a gene, ortholog associations will also be counted. |
None
|
get_associations
Retrieve paginated association records, with filter options
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
List[AssociationCategory]
|
Filter to only associations matching the specified categories. Defaults to None. |
None
|
predicate
|
List[AssociationPredicate]
|
Filter to only associations matching the specified predicates. Defaults to None. |
None
|
subject
|
Optional[List[str]]
|
Filter to only associations matching the specified subjects. Defaults to None. |
None
|
object
|
Optional[List[str]]
|
Filter to only associations matching the specified objects. Defaults to None. |
None
|
subject_closure
|
Optional[str]
|
Filter to only associations with the specified term ID as an ancestor of the subject. Defaults to None |
None
|
object_closure
|
Optional[str]
|
Filter to only associations with the specified term ID as an ancestor of the object. Defaults to None |
None
|
entity
|
Optional[List[str]]
|
Filter to only associations where the specified entities are the subject or the object. Defaults to None. |
None
|
q
|
Optional[str]
|
Query string to search within matches. Defaults to None. |
None
|
facet_fields
|
Optional[List[str]]
|
List of fields to include facet counts for. Defaults to None. |
None
|
facet_queries
|
Optional[List[str]]
|
List of queries to include facet counts for. Defaults to None. |
None
|
filter_queries
|
Optional[List[str]]
|
List of queries to filter results by. Defaults to None. |
None
|
compact
|
bool
|
Return compact results with fewer fields. Defaults to False. |
False
|
offset
|
int
|
Result offset, for pagination. Defaults to 0. |
0
|
limit
|
int
|
Limit results to specified number. Defaults to 20. |
20
|
Returns:
| Name | Type | Description |
|---|---|---|
AssociationResults |
Union[AssociationResults, CompactAssociation]
|
Dataclass representing results of an association search. |
get_case_phenotype_matrix
Fetch case-phenotype matrix for a disease.
Execution flow: 1. Query for case-disease associations to get case list and count 2. Check count against limit, raise error if exceeded 3. Query for case-phenotype associations with JOIN (includes facets) 4. Build and return matrix response
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
disease_id
|
str
|
MONDO disease ID (e.g., "MONDO:0007078") |
required |
direct_only
|
bool
|
If True, only cases with exactly this disease |
True
|
limit
|
int
|
Maximum number of cases allowed |
200
|
Returns:
| Type | Description |
|---|---|
CasePhenotypeMatrixResponse
|
CasePhenotypeMatrixResponse with complete matrix data |
Raises:
| Type | Description |
|---|---|
ValueError
|
If case count exceeds limit |
get_counterpart_entities
Get a list of entities directly associated with this_entity fetched from associations in the Solr index
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
this_entity
|
Entity
|
The entity to get associations for |
required |
entity
|
str
|
an entity ID occurring in either the subject or object. Defaults to None. |
None
|
subject
|
str
|
an entity ID occurring in the subject. Defaults to None. |
None
|
predicate
|
str
|
a predicate value. Defaults to None. |
None
|
object
|
str
|
an entity ID occurring in the object. Defaults to None. |
None
|
get_entity
Retrieve a specific entity by exact ID match, with optional extras
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
id of the entity to search for. |
required |
extra
|
bool
|
Whether to include association counts and hierarchy in the response. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Entity |
Optional[Union[Node, Entity]]
|
Dataclass representing results of an entity search. |
Node |
Optional[Union[Node, Entity]]
|
Dataclass representing results of an entity search with extra=True. |
get_entity_grid
Fetch entity grid for any supported grid type.
This is a generic 2-hop query that works for multiple grid types: - case-phenotype: Disease -> Case × Phenotype - disease-phenotype: Gene -> Disease × Phenotype - ortholog-phenotype: Gene -> Ortholog × Phenotype
Execution flow: 1. Get grid configuration for the specified type 2. Query for column entities (first hop) 3. Check count against limit 4. Query for row associations via JOIN (second hop, includes facets) 5. Build and return grid response
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context_id
|
str
|
The context entity ID (e.g., disease ID, gene ID) |
required |
grid_type
|
str
|
The type of grid to generate |
required |
direct_only
|
bool
|
If True, only direct associations; if False, use closure |
True
|
limit
|
int
|
Maximum number of column entities allowed |
200
|
Returns:
| Type | Description |
|---|---|
EntityGridResponse
|
EntityGridResponse with complete grid data |
Raises:
| Type | Description |
|---|---|
ValueError
|
If column count exceeds limit or grid type is unknown |
get_generic_entity_grid
Fetch generic entity grid with configurable association categories.
This method allows specifying association categories directly, enabling flexible grid construction without predefined configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context_id
|
str
|
The context entity ID (e.g., gene ID, disease ID) |
required |
column_assoc_categories
|
List[str]
|
List of association category values for context -> column |
required |
row_assoc_categories
|
List[str]
|
List of association category values for column -> row |
required |
row_grouping
|
str
|
How to group rows ("histopheno" or "none") |
'histopheno'
|
group_columns_by_category
|
bool
|
If True, sort columns by their source association category |
False
|
direct_only
|
bool
|
If True, only direct associations; if False, use closure |
True
|
limit
|
int
|
Maximum number of column entities |
500
|
Returns:
| Type | Description |
|---|---|
EntityGridResponse
|
EntityGridResponse with complete grid data |
Raises:
| Type | Description |
|---|---|
ValueError
|
If column count exceeds limit or configuration is invalid |
get_histopheno
Get histopheno counts for a given subject_closure
get_multi_entity_associations
Get associations between multiple entities and counterparts of a given category
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity
|
List[str]
|
List of entity IDs to get associations for |
required |
counterpart_category
|
List[str]
|
List of categories of counterpart entity to get associations for. Defaults to None. |
None
|
offset
|
int
|
Result offset, for pagination. Defaults to 0. |
0
|
limit
|
int
|
Limit results to specified number. Defaults to 20. |
required |
limit_per_group
|
int
|
Limit results to specified number per group. Defaults to 20. |
20
|
ground_entity
search
Search for entities by label, with optional filters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
str
|
Query string. Defaults to ":". |
'*:*'
|
offset
|
int
|
Result offset, for pagination. Defaults to 0. |
0
|
limit
|
int
|
Limit results to specified number. Defaults to 20. |
20
|
category
|
List[str]
|
Filter to only entities matching the specified categories. Defaults to None. |
None
|
in_taxon_label
|
List[str]
|
Filter to only entities matching the specified taxon label. Defaults to None. |
None
|
facet_fields
|
List[str]
|
List of fields to include facet counts for. Defaults to None. |
None
|
facet_queries
|
List[str]
|
List of queries to include facet counts for. Defaults to None. |
None
|
filter_queries
|
List[str]
|
List of queries to filter results by. Defaults to None. |
None
|
sort
|
str
|
Sort results by the specified field. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
SearchResults |
SearchResults
|
Dataclass representing results of a search. |
solr_is_available
Check if the Solr instance is available