diff --git a/packages/core-data/src/types/RuntimeConfig.js b/packages/core-data/src/types/RuntimeConfig.js index 68621d09..c89ca347 100644 --- a/packages/core-data/src/types/RuntimeConfig.js +++ b/packages/core-data/src/types/RuntimeConfig.js @@ -34,7 +34,8 @@ export type RuntimeConfig = { facets?: { include?: string[], exclude?: string[] - } + }, + default_sort?: string }, core_data: { project_ids: number[], diff --git a/packages/core-data/src/utils/Peripleo.js b/packages/core-data/src/utils/Peripleo.js index 02dea74e..27b85928 100644 --- a/packages/core-data/src/utils/Peripleo.js +++ b/packages/core-data/src/utils/Peripleo.js @@ -30,7 +30,8 @@ const normalize = (config: RuntimeConfig) => ({ typesense: { ...config.typesense, host: config.typesense.host || '443', - protocol: config.typesense.protocol || 'https' + protocol: config.typesense.protocol || 'https', + sort_by: `_text_match:desc${config.typesense.default_sort ? `,${config.typesense.default_sort}:asc` : ''}` }, core_data: { ...config.core_data, diff --git a/packages/core-data/src/utils/Typesense.js b/packages/core-data/src/utils/Typesense.js index f44be56c..92c26786 100644 --- a/packages/core-data/src/utils/Typesense.js +++ b/packages/core-data/src/utils/Typesense.js @@ -14,7 +14,8 @@ type TypesenseConfig = { limit: number, port: number, protocol: string, - query_by: string + query_by: string, + sort_by: string }; const ATTRIBUTE_DELIMITER = '.'; @@ -100,7 +101,8 @@ const createTypesenseAdapter = (config: TypesenseConfig, options = {}) => ( geoLocationField: 'coordinates', additionalSearchParameters: { query_by: config.query_by, - limit: config.limit || 250 + limit: config.limit || 250, + sort_by: config.sort_by }, ...options })