mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-09 19:22:51 +00:00
feat: provide context based search
This commit is contained in:
committed by
Karl-Philipp Wulfert
parent
37e5f6c490
commit
3242411768
@@ -13,6 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||
import {SCSearchContext} from '../../../types/config/Backend';
|
||||
import {SCSearchFilter} from '../../../types/filters/Abstract';
|
||||
import {SCSearchSort} from '../../../types/sorts/Abstract';
|
||||
import {
|
||||
@@ -37,7 +38,12 @@ export interface SCSearchRequest extends SCSearchQuery {
|
||||
*/
|
||||
export interface SCSearchQuery {
|
||||
/**
|
||||
* A filter structure that combines any number of filters with boolean methods ('AND', 'OR', 'NOT')
|
||||
* The context name from where the search query was initiated
|
||||
*/
|
||||
context?: SCSearchContext;
|
||||
|
||||
/**
|
||||
* A filter structure that combines any number of filters with boolean methods ('AND', 'OR', 'NOT')
|
||||
*/
|
||||
filter?: SCSearchFilter;
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
/**
|
||||
* Capsulation for a map with a string as key with values of type `T`
|
||||
*
|
||||
*
|
||||
* !!! BEWARE !!!
|
||||
* Can't be refactored to a `Map<K, V>`, because it can't be serialized via JSON.stringify(map)
|
||||
*
|
||||
*
|
||||
* @typeparam T Can be any type.
|
||||
*/
|
||||
export interface SCMap<T> {
|
||||
@@ -27,3 +27,20 @@ export interface SCMap<T> {
|
||||
*/
|
||||
[key: string]: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricted map with keys, limited to values of `U`, and corresponding values of type `T`
|
||||
*
|
||||
* !!! BEWARE !!!
|
||||
* Can't be refactored to a `Map<K, V>`, because it can't be serialized via JSON.stringify(map)
|
||||
* Also note, that this is a type not an interface
|
||||
*
|
||||
* @typeparam U Must be a type the `in` operator can be applied to and contains only strings or numbers
|
||||
* @typeparam T Can be any type
|
||||
*/
|
||||
export type SCRestrictedMap<U extends string | number, T> = {
|
||||
/**
|
||||
* One value for each key
|
||||
*/
|
||||
[key in U]: T
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import {SCThingType} from '../../Thing';
|
||||
import {SCSearchSortType} from '../sorts/Abstract';
|
||||
import {SCUuid} from '../UUID';
|
||||
import {SCMap} from './../Map';
|
||||
import {SCMap, SCRestrictedMap} from './../Map';
|
||||
import {SCMonitoringConfiguration} from './Monitoring';
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ export interface SCBackendConfigurationSortableField {
|
||||
|
||||
/**
|
||||
* A list of SC types on which this field exists
|
||||
*
|
||||
*
|
||||
* If no type is given it is assumed it exists on every type
|
||||
*/
|
||||
onlyOnTypes?: SCThingType[];
|
||||
@@ -84,10 +84,27 @@ export interface SCBackendConfigurationSortableField {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible context names to be used by the search request
|
||||
*/
|
||||
export type SCSearchContext =
|
||||
| 'default'
|
||||
| 'dining'
|
||||
| 'place';
|
||||
|
||||
/**
|
||||
* A boosting configuration for one context
|
||||
*/
|
||||
export type SCBackendConfigurationSearchBoostingContext =
|
||||
SCRestrictedMap<
|
||||
SCSearchContext,
|
||||
SCBackendConfigurationSearchBoostingType[]
|
||||
>;
|
||||
|
||||
/**
|
||||
* A boosting configuration for one SCType
|
||||
*/
|
||||
export interface SCBackendConfigurationSearchBoosting {
|
||||
export interface SCBackendConfigurationSearchBoostingType {
|
||||
|
||||
/**
|
||||
* The factor of which the scores matching this type should be multiplied by
|
||||
@@ -98,7 +115,7 @@ export interface SCBackendConfigurationSearchBoosting {
|
||||
* Outer-Map:
|
||||
* Fields of this type that should be boosted if they match a given value
|
||||
* For nest fields you can use the `.` as a separator. For example `academicTerms.acronym`
|
||||
*
|
||||
*
|
||||
* Inner-map:
|
||||
* Value of the field that should be boosted by the given number
|
||||
* For example `"SS 2019": 2`
|
||||
@@ -143,7 +160,7 @@ export interface SCBackendInternalConfiguration {
|
||||
* The resulting scores of matching objects can be boosted (multiplied by a number) to change the order in the
|
||||
* set of results
|
||||
*/
|
||||
boostings: SCBackendConfigurationSearchBoosting[];
|
||||
boostings: SCBackendConfigurationSearchBoostingContext;
|
||||
|
||||
/**
|
||||
* Configuration of the database
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"errorNames": [],
|
||||
"instance": {
|
||||
"query": "*",
|
||||
"context": "default",
|
||||
"filter": {
|
||||
"arguments": {
|
||||
"filters": [
|
||||
|
||||
Reference in New Issue
Block a user