mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 01:22:54 +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/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route';
|
||||||
|
import {SCSearchContext} from '../../../types/config/Backend';
|
||||||
import {SCSearchFilter} from '../../../types/filters/Abstract';
|
import {SCSearchFilter} from '../../../types/filters/Abstract';
|
||||||
import {SCSearchSort} from '../../../types/sorts/Abstract';
|
import {SCSearchSort} from '../../../types/sorts/Abstract';
|
||||||
import {
|
import {
|
||||||
@@ -37,7 +38,12 @@ export interface SCSearchRequest extends SCSearchQuery {
|
|||||||
*/
|
*/
|
||||||
export interface 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;
|
filter?: SCSearchFilter;
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Capsulation for a map with a string as key with values of type `T`
|
* Capsulation for a map with a string as key with values of type `T`
|
||||||
*
|
*
|
||||||
* !!! BEWARE !!!
|
* !!! BEWARE !!!
|
||||||
* Can't be refactored to a `Map<K, V>`, because it can't be serialized via JSON.stringify(map)
|
* 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.
|
* @typeparam T Can be any type.
|
||||||
*/
|
*/
|
||||||
export interface SCMap<T> {
|
export interface SCMap<T> {
|
||||||
@@ -27,3 +27,20 @@ export interface SCMap<T> {
|
|||||||
*/
|
*/
|
||||||
[key: string]: 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 {SCThingType} from '../../Thing';
|
||||||
import {SCSearchSortType} from '../sorts/Abstract';
|
import {SCSearchSortType} from '../sorts/Abstract';
|
||||||
import {SCUuid} from '../UUID';
|
import {SCUuid} from '../UUID';
|
||||||
import {SCMap} from './../Map';
|
import {SCMap, SCRestrictedMap} from './../Map';
|
||||||
import {SCMonitoringConfiguration} from './Monitoring';
|
import {SCMonitoringConfiguration} from './Monitoring';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +72,7 @@ export interface SCBackendConfigurationSortableField {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of SC types on which this field exists
|
* A list of SC types on which this field exists
|
||||||
*
|
*
|
||||||
* If no type is given it is assumed it exists on every type
|
* If no type is given it is assumed it exists on every type
|
||||||
*/
|
*/
|
||||||
onlyOnTypes?: SCThingType[];
|
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
|
* 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
|
* The factor of which the scores matching this type should be multiplied by
|
||||||
@@ -98,7 +115,7 @@ export interface SCBackendConfigurationSearchBoosting {
|
|||||||
* Outer-Map:
|
* Outer-Map:
|
||||||
* Fields of this type that should be boosted if they match a given value
|
* 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`
|
* For nest fields you can use the `.` as a separator. For example `academicTerms.acronym`
|
||||||
*
|
*
|
||||||
* Inner-map:
|
* Inner-map:
|
||||||
* Value of the field that should be boosted by the given number
|
* Value of the field that should be boosted by the given number
|
||||||
* For example `"SS 2019": 2`
|
* 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
|
* The resulting scores of matching objects can be boosted (multiplied by a number) to change the order in the
|
||||||
* set of results
|
* set of results
|
||||||
*/
|
*/
|
||||||
boostings: SCBackendConfigurationSearchBoosting[];
|
boostings: SCBackendConfigurationSearchBoostingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration of the database
|
* Configuration of the database
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"errorNames": [],
|
"errorNames": [],
|
||||||
"instance": {
|
"instance": {
|
||||||
"query": "*",
|
"query": "*",
|
||||||
|
"context": "default",
|
||||||
"filter": {
|
"filter": {
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"filters": [
|
"filters": [
|
||||||
|
|||||||
Reference in New Issue
Block a user