getTopLevelPredicate
Searches through a list of filters and finds a specific predicate that should be appended at the top level of a search (i.e., has special requirements for combining with other predicates). Also verifies that the predicate is not combined in any invalid ways.
Combination Requirements:
- Only ONE filter can have a predicate with the target field
- Only ONE predicate with the target field can exist
- The predicate can only be ANDed to other predicates
- The predicate's field value MUST be a string or boolean (not string[] or IMatchOptions)
Example: Portal's bbox field cannot be conditionally searched. Any value provided will always be applied as a top-level filter.
- Valid:
?bbox=1,2,3,4&filter=type:CSV
- Invalid: `?filter=type:CSV OR (type:PDF AND bbox=1,2,3,4)
Parameters
Parameter | Type | Default | Notes |
---|---|---|---|
field Required | string |
the field of the desired predicate |
|
filters Required | IFilter[] |
filters to be searched / validated |
Returns
the predicate (if present and all requirements are met)
Property | Type | Notes |
---|
Function defined in common/src/search/_internal/commonHelpers/getTopLevelPredicate.ts:22