mario.CoreModel.search
- CoreModel.search(item=None, search=None, ignore_case=True, *, region=None, flat=False)#
Search index values matching a pattern within one set or across all sets.
- Parameters:
item – Optional set name to search in, such as
RegionorSector. When omitted, search every set and return grouped matches.search – Regular-expression fragment matched against the labels.
ignore_case – When
True, perform a case-insensitive search.region – Optional region to search. Each matching set then returns a list. Mutually exclusive with
flat=True.flat – When
True, search the union of distinct labels and return a list for each matching set, including regional classifications.
- Returns:
Matching labels in their stored order for a common classification, or
{region: matching_labels}for a regional classification. Regions without matches are omitted. Withregionorflat=True, return a list. Global searches always return a dictionary keyed by matching set, using these same value types.- Return type:
list | dict
Searching one set normally returns an ordered list. In the special case of regional classifications, the result is a dictionary whose keys are only the regions containing matches:
db.search("Activity", "^A_ADVERT$")
# {"IT": ["A_ADVERT"], "DE": ["A_ADVERT"], ...}
Explicitly request the ordered union of distinct matching labels, or limit the search to one region:
db.search("Activity", "^A_ADVERT$", flat=True)
# ["A_ADVERT"]
db.search("Activity", "^A_ADVERT$", region="IT")
# ["A_ADVERT"]
region and flat=True are mutually exclusive. A regional set with no
matches returns {}; a list-shaped search with no matches returns [].
The default result shape depends on the classification before filtering, even
if the matching lists happen to be identical in every region.
Global searches keep their outer grouping by set and use the same result shapes inside each group:
db.search("^A_ADVERT$")
# {"Activity": {"IT": ["A_ADVERT"], "DE": ["A_ADVERT"], ...}, ...}
db.search("^A_ADVERT$", flat=True)
# {"Activity": ["A_ADVERT"], ...}
Set aliases, regular expressions, case matching and existing positional arguments retain their previous behavior. Searches read materialized index views without computing matrices.