Commit 32424117 authored by Michel Jonathan Schmitz's avatar Michel Jonathan Schmitz Committed by krlwlfrt
Browse files

feat: provide context based search

parent 37e5f6c4
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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 {
@@ -36,6 +37,11 @@ export interface SCSearchRequest extends SCSearchQuery {
 * A search query
 */
export interface SCSearchQuery {
  /**
   * 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')
   */
+19 −2
Original line number Diff line number Diff line
@@ -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
};
+22 −5
Original line number Diff line number Diff line
@@ -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';

/**
@@ -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
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
  "errorNames": [],
  "instance": {
    "query": "*",
    "context": "default",
    "filter": {
      "arguments": {
        "filters": [