mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-03 12:02:53 +00:00
fix: use specific time from filter if defined
This commit is contained in:
committed by
Rainer Killinger
parent
8dbb3ca19a
commit
80e62496f0
@@ -57,6 +57,8 @@ function escapeESReservedCharacters(str: string): string {
|
||||
|
||||
/**
|
||||
* Builds a boolean filter. Returns an elasticsearch boolean filter
|
||||
* @param booleanFilter a search boolean filter for the retrieval of the data
|
||||
* @returns elasticsearch boolean arguments object
|
||||
*/
|
||||
export function buildBooleanFilter(booleanFilter: SCSearchBooleanFilter): ESBooleanFilterArguments<unknown> {
|
||||
|
||||
@@ -107,7 +109,8 @@ export function buildFilter(filter: SCSearchFilter): ESTermFilter | ESGeoDistanc
|
||||
};
|
||||
} = {};
|
||||
startRangeFilter[filter.arguments.fromField] = {
|
||||
lte: 'now',
|
||||
lte: typeof filter.arguments.time !== 'undefined'
|
||||
? filter.arguments.time : 'now',
|
||||
};
|
||||
|
||||
const endRangeFilter: {
|
||||
@@ -119,7 +122,8 @@ export function buildFilter(filter: SCSearchFilter): ESTermFilter | ESGeoDistanc
|
||||
};
|
||||
} = {};
|
||||
endRangeFilter[filter.arguments.toField] = {
|
||||
gte: 'now',
|
||||
gte: typeof filter.arguments.time !== 'undefined'
|
||||
? filter.arguments.time : 'now',
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -158,7 +162,7 @@ export function buildFilter(filter: SCSearchFilter): ESTermFilter | ESGeoDistanc
|
||||
};
|
||||
case 'distance':
|
||||
const geoObject: ESGeoDistanceFilterArguments = {
|
||||
distance: `${filter.arguments.distanceInM}m`,
|
||||
distance: `${filter.arguments.distance}m`,
|
||||
};
|
||||
geoObject[filter.arguments.field] = {
|
||||
lat: filter.arguments.position[1],
|
||||
@@ -172,8 +176,6 @@ export function buildFilter(filter: SCSearchFilter): ESTermFilter | ESGeoDistanc
|
||||
return {
|
||||
bool: buildBooleanFilter(filter),
|
||||
};
|
||||
default:
|
||||
throw new Error('Unknown Filter type');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +267,7 @@ function buildFunctionsForBoostingTypes(
|
||||
* Builds body for Elasticsearch requests
|
||||
* @param params Parameters for querying the backend
|
||||
* @param defaultConfig Default configuration of the backend
|
||||
* @param elasticsearchConfig Elasticsearch configuration
|
||||
* @returns ElasticsearchQuery (body of a search-request)
|
||||
*/
|
||||
export function buildQuery(
|
||||
@@ -356,9 +359,9 @@ export function buildQuery(
|
||||
},
|
||||
|
||||
};
|
||||
} else {
|
||||
throw new Error('Query Type is not supported. Check your config file and reconfigure your elasticsearch query');
|
||||
}
|
||||
} else {
|
||||
throw new Error('Unsupported query type. Check your config file and reconfigure your elasticsearch query');
|
||||
}
|
||||
|
||||
const functionScoreQuery: ESFunctionScoreQuery = {
|
||||
|
||||
Reference in New Issue
Block a user