mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 08:02:55 +00:00
feat: add support for multiple values in value filter
This commit is contained in:
committed by
Rainer Killinger
parent
15ac0e2f59
commit
de60311bd0
@@ -274,14 +274,21 @@ export interface ElasticsearchConfig {
|
||||
/**
|
||||
* An elasticsearch term filter
|
||||
*/
|
||||
export interface ESTermFilter {
|
||||
export type ESTermFilter = {
|
||||
/**
|
||||
* Definition of a term to match
|
||||
*/
|
||||
term: {
|
||||
[fieldName: string]: string;
|
||||
};
|
||||
}
|
||||
} | {
|
||||
/**
|
||||
* Definition of terms to match (or)
|
||||
*/
|
||||
terms: {
|
||||
[fieldName: string]: string[];
|
||||
};
|
||||
};
|
||||
|
||||
export interface ESGenericRange<T> {
|
||||
/**
|
||||
@@ -381,7 +388,7 @@ export interface ESGeoDistanceFilterArguments {
|
||||
|
||||
[fieldName: string]: {
|
||||
/**
|
||||
* Latitute
|
||||
* Latitude
|
||||
*/
|
||||
lat: number;
|
||||
|
||||
|
||||
@@ -99,11 +99,14 @@ export function buildFilter(filter: SCSearchFilter):
|
||||
|
||||
switch (filter.type) {
|
||||
case 'value':
|
||||
const filterObj: { [field: string]: string; } = {};
|
||||
filterObj[`${filter.arguments.field}.raw`] = filter.arguments.value;
|
||||
|
||||
return {
|
||||
term: filterObj,
|
||||
return Array.isArray(filter.arguments.value) ? {
|
||||
terms: {
|
||||
[`${filter.arguments.field}.raw`]: filter.arguments.value,
|
||||
},
|
||||
} : {
|
||||
term: {
|
||||
[`${filter.arguments.field}.raw`]: filter.arguments.value,
|
||||
},
|
||||
};
|
||||
case 'availability':
|
||||
const startRangeFilter: {
|
||||
@@ -220,7 +223,7 @@ export function buildFilter(filter: SCSearchFilter):
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds scorings functions from boosting config
|
||||
* Builds scoring functions from boosting config
|
||||
* @param boostings Backend boosting configuration for contexts and types
|
||||
* @param context The context of the app from where the search was initiated
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user