Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ The environment variables used to configure the application:
- `IIIF_SERVER_ATTRIBUTION`: Attribution to add to the IIIF manifests
- `IIIF_SERVER_BASE_URL`: The public base URL of the application
- `IIIF_SERVER_VIEWER_URL`: The URL of the main IIIF viewer to use (the manifest URI will be added to this URL)
- `IIIF_SERVER_SEARCH_MODE`: The search mode to use: `fuzzy` (default) for fuzzy matching or `phrase` for exact phrase matching
- `IIIF_SERVER_HOT_FOLDER_PATH`: The path to the hot folder where new collections to be indexed are placed
- `IIIF_SERVER_HOT_FOLDER_PATTERN`: The pattern of a file in the root of a new collection to trigger indexing
- `IIIF_SERVER_DATA_ROOT_PATH`: The root path of the data storage
Expand Down
7 changes: 7 additions & 0 deletions src/lib/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface Config {
imageTierSeparator: string;
maxTasksPerWorker: number;
maxSearchResults: number;
searchMode: 'fuzzy' | 'phrase';
services: string[];
secret: string;
accessToken: string;
Expand Down Expand Up @@ -161,6 +162,12 @@ const config: Config = {
return (maxSearchResults > 0) ? maxSearchResults : 5000;
})(),

searchMode: (_ => {
const mode = process.env.IIIF_SERVER_SEARCH_MODE?.toLowerCase();
if (mode === 'phrase') return 'phrase' as const;
return 'fuzzy' as const;
})(),

services: (_ => {
if (!process.env.IIIF_SERVER_SERVICES || (process.env.IIIF_SERVER_SERVICES === 'null'))
throw new Error('Services to run are not defined');
Expand Down
4 changes: 2 additions & 2 deletions src/search/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ async function search(query: string, filters: { [field: string]: string | undefi
query: {
bool: {
must: {
[isPhraseMatch ? 'match_phrase' : 'match']: {
[isPhraseMatch || config.searchMode === 'phrase' ? 'match_phrase' : 'match']: {
text: {
query,
fuzziness: !isPhraseMatch ? 'AUTO' : undefined
fuzziness: !isPhraseMatch && config.searchMode === 'fuzzy' ? 'AUTO' : undefined
}
}
},
Expand Down