Skip to content

Commit c6e1157

Browse files
authored
Merge pull request #305 from performant-software/feature/sort-by
Allow default sort typesense configuration (#304)
2 parents bcf9ec4 + ef586f2 commit c6e1157

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

packages/core-data/src/types/RuntimeConfig.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export type RuntimeConfig = {
3434
facets?: {
3535
include?: string[],
3636
exclude?: string[]
37-
}
37+
},
38+
default_sort?: string
3839
},
3940
core_data: {
4041
project_ids: number[],

packages/core-data/src/utils/Peripleo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const normalize = (config: RuntimeConfig) => ({
3030
typesense: {
3131
...config.typesense,
3232
host: config.typesense.host || '443',
33-
protocol: config.typesense.protocol || 'https'
33+
protocol: config.typesense.protocol || 'https',
34+
sort_by: `_text_match:desc${config.typesense.default_sort ? `,${config.typesense.default_sort}:asc` : ''}`
3435
},
3536
core_data: {
3637
...config.core_data,

packages/core-data/src/utils/Typesense.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ type TypesenseConfig = {
1414
limit: number,
1515
port: number,
1616
protocol: string,
17-
query_by: string
17+
query_by: string,
18+
sort_by: string
1819
};
1920

2021
const ATTRIBUTE_DELIMITER = '.';
@@ -100,7 +101,8 @@ const createTypesenseAdapter = (config: TypesenseConfig, options = {}) => (
100101
geoLocationField: 'coordinates',
101102
additionalSearchParameters: {
102103
query_by: config.query_by,
103-
limit: config.limit || 250
104+
limit: config.limit || 250,
105+
sort_by: config.sort_by
104106
},
105107
...options
106108
})

0 commit comments

Comments
 (0)