diff --git a/src/core/protocol/routes/search/SearchRequest.ts b/src/core/protocol/routes/search/SearchRequest.ts
index 390d7d3c..90152930 100644
--- a/src/core/protocol/routes/search/SearchRequest.ts
+++ b/src/core/protocol/routes/search/SearchRequest.ts
@@ -13,6 +13,7 @@
* this program. If not, see .
*/
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;
diff --git a/src/core/types/Map.ts b/src/core/types/Map.ts
index 62220b8a..13d290d8 100644
--- a/src/core/types/Map.ts
+++ b/src/core/types/Map.ts
@@ -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`, because it can't be serialized via JSON.stringify(map)
- *
+ *
* @typeparam T Can be any type.
*/
export interface SCMap {
@@ -27,3 +27,20 @@ export interface SCMap {
*/
[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`, 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 = {
+ /**
+ * One value for each key
+ */
+ [key in U]: T
+};
diff --git a/src/core/types/config/Backend.ts b/src/core/types/config/Backend.ts
index 92e77e4e..7548546a 100644
--- a/src/core/types/config/Backend.ts
+++ b/src/core/types/config/Backend.ts
@@ -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
diff --git a/test/resources/SearchRequest.1.json b/test/resources/SearchRequest.1.json
index 21272976..a4473e58 100644
--- a/test/resources/SearchRequest.1.json
+++ b/test/resources/SearchRequest.1.json
@@ -2,6 +2,7 @@
"errorNames": [],
"instance": {
"query": "*",
+ "context": "default",
"filter": {
"arguments": {
"filters": [