Skip to content

Commit

Permalink
Merge pull request #305 from performant-software/feature/sort-by
Browse files Browse the repository at this point in the history
Allow default sort typesense configuration (#304)
  • Loading branch information
blms authored Dec 19, 2024
2 parents bcf9ec4 + ef586f2 commit c6e1157
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/core-data/src/types/RuntimeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export type RuntimeConfig = {
facets?: {
include?: string[],
exclude?: string[]
}
},
default_sort?: string
},
core_data: {
project_ids: number[],
Expand Down
3 changes: 2 additions & 1 deletion packages/core-data/src/utils/Peripleo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions packages/core-data/src/utils/Typesense.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ type TypesenseConfig = {
limit: number,
port: number,
protocol: string,
query_by: string
query_by: string,
sort_by: string
};

const ATTRIBUTE_DELIMITER = '.';
Expand Down Expand Up @@ -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
})
Expand Down

0 comments on commit c6e1157

Please sign in to comment.