Compare commits

..

1 Commits

Author SHA1 Message Date
bc0e219158 feat: improve search experience 2024-09-09 19:23:21 +02:00
29 changed files with 336 additions and 365 deletions

View File

@@ -8,8 +8,7 @@ const config = {
database: {
name: 'elasticsearch',
query: {
minMatch: '60%',
queryType: 'query_string',
fields: ["name"]
},
},
},

View File

@@ -39,7 +39,7 @@ const boostings = {
type: SCThingType.AcademicEvent,
},
{
factor: 1.6,
factor: 2,
type: SCThingType.Building,
},
{
@@ -85,7 +85,7 @@ const boostings = {
],
place: [
{
factor: 2,
factor: 3,
type: SCThingType.Building,
},
{

View File

@@ -17,12 +17,21 @@ const config = {
name: 'elasticsearch',
version: '8.4.2',
query: {
minMatch: '75%',
queryType: 'dis_max',
matchBoosting: 1.3,
fuzziness: 'AUTO',
cutoffFrequency: 0,
tieBreaker: 0,
type: 'best_fields',
fields: [
'identifiers^20',
'name^10',
'translations.*.name^10',
'alternateNames^10',
'translations.*.alternateNames^10',
'description^2',
'translations.*.description^2',
'categories^5',
],
},
searchAsYouTypeQuery: {
type: 'phrase_prefix',
fields: ['name.completion', 'name.completion._2gram', 'name.completion._3gram'],
},
},
},

View File

@@ -20,6 +20,8 @@ import {
IndicesGetAliasResponse,
SearchHit,
SearchResponse,
SearchTermSuggest,
SearchTermSuggestOption,
} from '@elastic/elasticsearch/lib/api/types.js';
import {SCConfigFile, SCSearchQuery, SCSearchResponse, SCThings, SCUuid} from '@openstapps/core';
import {Logger} from '@openstapps/logger';
@@ -47,6 +49,9 @@ import {
import {noUndefined} from './util/no-undefined.js';
import {retryCatch, RetryOptions} from './util/retry.js';
import {Feature, Point, Polygon} from 'geojson';
import {parseSuggestions} from './util/parse-suggestions.js';
import {buildScoringFunctions} from './query/boost/scoring-functions.js';
import {buildFilter} from './query/filter.js';
/**
* A database interface for elasticsearch
@@ -355,6 +360,39 @@ export class Elasticsearch implements Database {
throw new Error('You tried to PUT an non-existing object. PUT is only supported on existing objects.');
}
public async searchAsYouType(parameters: SCSearchQuery): Promise<SCSearchResponse> {
const result = await this.client.search({
_source: 'name',
query: {
function_score: {
functions: buildScoringFunctions(this.config.internal.boostings, parameters.context),
query: {
bool: {
must: {
multi_match: {
query: parameters.query,
type: 'bool_prefix',
fields: ['name.completion', 'name.completion._2gram', 'name.completion._3gram'],
},
},
should: [],
filter: parameters.filter === undefined ? undefined : buildFilter(parameters.filter),
},
},
score_mode: 'max',
boost_mode: 'multiply',
},
},
index: ACTIVE_INDICES_ALIAS,
allow_no_indices: true,
size: 5,
});
const suggestions = result.hits.hits.map(it => (it._source as any).name);
console.log(suggestions);
console.log(result.took);
}
/**
* Search all indexed data
* @param parameters search query
@@ -364,18 +402,23 @@ export class Elasticsearch implements Database {
throw new TypeError('Database is undefined. You have to configure the query build');
}
const esConfig: ElasticsearchConfig = {
name: this.config.internal.database.name as 'elasticsearch',
version: this.config.internal.database.version as string,
query: this.config.internal.database.query as
| ElasticsearchQueryDisMaxConfig
| ElasticsearchQueryQueryStringConfig
| undefined,
};
const esConfig = this.config.internal.database as object as ElasticsearchConfig;
const response: SearchResponse<SCThings> = await this.client.search({
aggs: aggregations,
query: buildQuery(parameters, this.config, esConfig),
suggest:
parameters.query === undefined
? undefined
: {
text: parameters.query,
terms: {
term: {
field: 'name',
suggest_mode: 'missing',
},
},
},
from: parameters.from,
index: ACTIVE_INDICES_ALIAS,
allow_no_indices: true,
@@ -395,6 +438,7 @@ export class Elasticsearch implements Database {
response.aggregations === undefined
? []
: parseAggregations(response.aggregations as Record<AggregateName, AggregationsMultiTermsBucket>),
suggestions: response.suggest === undefined ? undefined : parseSuggestions(response.suggest),
pagination: {
count: response.hits.hits.length,
offset: typeof parameters.from === 'number' ? parameters.from : 0,

View File

@@ -30,84 +30,21 @@ export const buildQuery = function buildQuery(
defaultConfig: SCConfigFile,
elasticsearchConfig: ElasticsearchConfig,
): QueryDslQueryContainer {
// if config provides a minMatch parameter, we use query_string instead of a match query
let query;
if (elasticsearchConfig.query === undefined) {
query = {
query_string: {
analyzer: 'search_german',
default_field: 'name',
minimum_should_match: '90%',
query: typeof parameters.query === 'string' ? parameters.query : '*',
},
};
} else if (elasticsearchConfig.query.queryType === 'query_string') {
query = {
query_string: {
analyzer: 'search_german',
default_field: 'name',
minimum_should_match: elasticsearchConfig.query.minMatch,
query: typeof parameters.query === 'string' ? parameters.query : '*',
},
};
} else if (elasticsearchConfig.query.queryType === 'dis_max') {
if (typeof parameters.query === 'string' && parameters.query !== '*') {
query = {
dis_max: {
boost: 1.2,
queries: [
{
match: {
name: {
boost: elasticsearchConfig.query.matchBoosting,
fuzziness: elasticsearchConfig.query.fuzziness,
query: parameters.query,
},
},
},
{
query_string: {
default_field: 'name',
minimum_should_match: elasticsearchConfig.query.minMatch,
query: parameters.query,
},
},
],
tie_breaker: elasticsearchConfig.query.tieBreaker,
},
};
}
} else {
throw new Error(
'Unsupported query type. Check your config file and reconfigure your elasticsearch query',
);
}
const functionScoreQuery: QueryDslQueryContainer = {
return {
function_score: {
functions: buildScoringFunctions(defaultConfig.internal.boostings, parameters.context),
query: {
bool: {
minimum_should_match: 0, // if we have no should, nothing can match
must: [],
must:
parameters.query === undefined || parameters.query === '' || parameters.query === '*'
? {match_all: {}}
: {multi_match: {...elasticsearchConfig.query, query: parameters.query}},
should: [],
filter: parameters.filter === undefined ? undefined : buildFilter(parameters.filter),
},
},
score_mode: 'multiply',
score_mode: 'max',
boost_mode: 'multiply',
},
};
const mustMatch = functionScoreQuery.function_score?.query?.bool?.must;
if (Array.isArray(mustMatch)) {
if (query !== undefined) {
mustMatch.push(query);
}
if (parameters.filter !== undefined) {
mustMatch.push(buildFilter(parameters.filter));
}
}
return functionScoreQuery;
};

View File

@@ -13,68 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* A configuration for using the Dis Max Query
*
* See https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-dis-max-query.html for further
* explanation of what the parameters mean
*/
export interface ElasticsearchQueryDisMaxConfig {
/**
* Relative (to a total number of documents) or absolute number to exclude meaningless matches that frequently appear
*/
cutoffFrequency: number;
/**
* The maximum allowed Levenshtein Edit Distance (or number of edits)
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/common-options.html#fuzziness
*/
fuzziness: number | string;
/**
* Increase the importance (relevance score) of a field
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping-boost.html
*/
matchBoosting: number;
/**
* Minimal number (or percentage) of words that should match in a query
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-minimum-should-match.html
*/
minMatch: string;
/**
* Type of the query - in this case 'dis_max' which is a union of its subqueries
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-dis-max-query.html
*/
queryType: 'dis_max';
/**
* Changes behavior of default calculation of the score when multiple results match
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-multi-match-query.html#tie-breaker
*/
tieBreaker: number;
}
/**
* A configuration for using Query String Query
*
* See https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-query-string-query.html for further
* explanation of what the parameters mean
*/
export interface ElasticsearchQueryQueryStringConfig {
/**
* Minimal number (or percentage) of words that should match in a query
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-minimum-should-match.html
*/
minMatch: string;
/**
* Type of the query - in this case 'query_string' which uses a query parser in order to parse content
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-query-string-query.html
*/
queryType: 'query_string';
}
import {QueryDslMultiMatchQuery} from '@elastic/elasticsearch/lib/api/types.js';
/**
* An config file for the elasticsearch database interface
@@ -105,7 +44,12 @@ export interface ElasticsearchConfig {
/**
* Configuration for using queries
*/
query?: ElasticsearchQueryDisMaxConfig | ElasticsearchQueryQueryStringConfig;
query: Omit<QueryDslMultiMatchQuery, 'query'>;
/**
*
*/
searchAsYouTypeQuery: Omit<QueryDslMultiMatchQuery, 'query'>;
/**
* Version of the used elasticsearch

View File

@@ -0,0 +1,28 @@
import {
SearchSuggest,
SearchTermSuggest,
SearchTermSuggestOption,
SuggestionName,
} from '@elastic/elasticsearch/lib/api/types.js';
import {SCSearchSuggestions} from '@openstapps/core';
/**
* Parse ES Suggestions to SC Search Suggestions
*/
export function parseSuggestions(suggest: Record<SuggestionName, SearchSuggest[]>): SCSearchSuggestions {
const termsSuggestions =
suggest.terms === undefined
? []
: (suggest.terms as SearchTermSuggest[])
?.map(
({text, options}) =>
[
text,
(options as SearchTermSuggestOption[] | undefined)?.map(({text}) => text) ?? [],
] as const,
)
.filter(([, suggestions]) => suggestions.length > 0) ?? [];
return {
terms: termsSuggestions.length === 0 ? undefined : Object.fromEntries(termsSuggestions),
};
}

142
flake.nix
View File

@@ -4,86 +4,68 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
let
aapt2buildToolsVersion = "33.0.2";
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: rec {
fontMin = prev.python311.withPackages (
ps:
with ps;
[
brotli
fonttools
]
++ (with fonttools.optional-dependencies; [ woff ])
);
android = prev.androidenv.composeAndroidPackages {
buildToolsVersions = [
"34.0.0"
aapt2buildToolsVersion
];
platformVersions = [ "34" ];
outputs = {
self,
nixpkgs,
flake-utils,
}: let
aapt2buildToolsVersion = "33.0.2";
in
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: rec {
fontMin = prev.python311.withPackages (ps: with ps; [brotli fonttools] ++ (with fonttools.optional-dependencies; [woff]));
android = prev.androidenv.composeAndroidPackages {
buildToolsVersions = ["30.0.3" aapt2buildToolsVersion];
platformVersions = ["33"];
};
cypress = prev.cypress.overrideAttrs (cyPrev: rec {
version = "13.2.0";
src = prev.fetchzip {
url = "https://cdn.cypress.io/desktop/${version}/linux-x64/cypress.zip";
hash = "sha256-9o0nprGcJhudS1LNm+T7Vf0Dwd1RBauYKI+w1FBQ3ZM=";
};
cypress = prev.cypress.overrideAttrs (cyPrev: rec {
version = "13.2.0";
src = prev.fetchzip {
url = "https://cdn.cypress.io/desktop/${version}/linux-x64/cypress.zip";
hash = "sha256-9o0nprGcJhudS1LNm+T7Vf0Dwd1RBauYKI+w1FBQ3ZM=";
};
});
nodejs = prev.nodejs_18;
corepack = prev.corepack_18;
})
];
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
});
nodejs = prev.nodejs_18;
})
];
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
androidFhs = pkgs.buildFHSUserEnv {
name = "android-env";
targetPkgs = pkgs: with pkgs; [ ];
runScript = "bash";
profile = ''
export ALLOW_NINJA_ENV=true
export USE_CCACHE=1
export LD_LIBRARY_PATH=/usr/lib:/usr/lib32
'';
};
in
{
devShell = pkgs.mkShell rec {
nativeBuildInputs = [ androidFhs ];
buildInputs = with pkgs; [
nodejs
corepack
# tools
curl
jq
fontMin
cypress
# android
jdk17
android.androidsdk
];
ANDROID_JAVA_HOME = "${pkgs.jdk.home}";
ANDROID_SDK_ROOT = "${pkgs.android.androidsdk}/libexec/android-sdk";
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${aapt2buildToolsVersion}/aapt2";
CYPRESS_INSTALL_BINARY = "0";
CYPRESS_RUN_BINARY = "${pkgs.cypress}/bin/Cypress";
};
}
);
};
androidFhs = pkgs.buildFHSUserEnv {
name = "android-env";
targetPkgs = pkgs: with pkgs; [];
runScript = "bash";
profile = ''
export ALLOW_NINJA_ENV=true
export USE_CCACHE=1
export LD_LIBRARY_PATH=/usr/lib:/usr/lib32
'';
};
in {
devShell = pkgs.mkShell rec {
nativeBuildInputs = [androidFhs];
buildInputs = with pkgs; [
nodejs
corepack
# tools
curl
jq
fontMin
cypress
# android
jdk17
android.androidsdk
];
ANDROID_JAVA_HOME = "${pkgs.jdk.home}";
ANDROID_SDK_ROOT = "${pkgs.android.androidsdk}/libexec/android-sdk";
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${aapt2buildToolsVersion}/aapt2";
CYPRESS_INSTALL_BINARY = "0";
CYPRESS_RUN_BINARY = "${pkgs.cypress}/bin/Cypress";
};
});
}

View File

@@ -1,11 +1,5 @@
# @openstapps/app
## 3.3.3
### Patch Changes
- 496b50d8: Bug fixes and Android target sdk version is now 34
## 3.3.2
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "@openstapps/app",
"description": "The generic app tailored to fulfill needs of German universities, written using Ionic Framework.",
"version": "3.3.3",
"version": "3.3.2",
"private": true,
"license": "GPL-3.0-only",
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
@@ -97,7 +97,7 @@
"form-data": "4.0.0",
"geojson": "0.5.0",
"ionic-appauth": "0.9.0",
"jsonpath-plus": "10.0.6",
"jsonpath-plus": "6.0.1",
"maplibre-gl": "4.0.2",
"material-symbols": "0.17.1",
"moment": "2.30.1",

View File

@@ -81,6 +81,7 @@ export class AuthHelperService {
user[key as keyof SCUserConfiguration] = JSONPath({
path: this.userConfigurationMap[key as keyof SCUserConfiguration] as string,
json: userInfo,
preventEval: true,
})[0];
}
if (user.givenName && user.givenName.length > 0 && user.familyName && user.familyName.length > 0) {

View File

@@ -67,8 +67,7 @@ describe('ConfigProvider', () => {
it('should fetch app configuration', async () => {
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
await configProvider.fetch();
const result = configProvider.config;
const result = await configProvider.fetch();
expect(result).toEqual(sampleIndexResponse);
});
@@ -111,7 +110,7 @@ describe('ConfigProvider', () => {
expect(storageProviderSpy.has).toHaveBeenCalled();
expect(storageProviderSpy.get).toHaveBeenCalledTimes(0);
expect(configProvider.client.handshake).toHaveBeenCalled();
expect(configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
expect(await configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
});
it('should throw error on failed initialisation', async () => {
@@ -193,31 +192,4 @@ describe('ConfigProvider', () => {
expect(configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
});
it('should fetch new config from remote on init', async () => {
storageProviderSpy.has.and.returnValue(Promise.resolve(true));
storageProviderSpy.get.and.returnValue(Promise.resolve(sampleIndexResponse));
spyOn(configProvider, 'fetch');
await configProvider.init();
expect(configProvider.fetch).toHaveBeenCalled();
});
it('should update the local config with the one from remote', async () => {
storageProviderSpy.has.and.returnValue(Promise.resolve(true));
storageProviderSpy.get.and.returnValue(Promise.resolve(sampleIndexResponse));
const newConfig = structuredClone(sampleIndexResponse);
newConfig.app.name = 'New app name';
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(newConfig));
await configProvider.init();
// Validate that the initial configuration is loaded
expect(configProvider.getValue('name')).toEqual(sampleIndexResponse.app.name);
// Fetch the new configuration from the remote
await configProvider.fetch();
// Validate that the new configuration is now set
expect(configProvider.getValue('name')).toEqual(newConfig.app.name);
});
});

View File

@@ -83,20 +83,17 @@ export class ConfigProvider {
/**
* Fetches configuration from backend
*/
async fetch(): Promise<void> {
async fetch(): Promise<SCIndexResponse> {
try {
const isOffline = await firstValueFrom(this.internetConnectionService.offline$);
if (isOffline) {
throw new Error('Device is offline.');
} else {
const fetchedConfig: SCIndexResponse = await this.client.handshake(this.scVersion);
await this.set(fetchedConfig);
this.logger.log(`Configuration updated from remote`);
return await this.client.handshake(this.scVersion);
}
} catch (error) {
const error_ = error instanceof Error ? new ConfigFetchError(error.message) : new ConfigFetchError();
this.logger.warn(`Failed to fetch remote configuration:`, error_);
throw error_; // Rethrow the error to handle it in init()
throw error_;
}
}
@@ -124,33 +121,40 @@ export class ConfigProvider {
/**
* Initialises the ConfigProvider
* @throws ConfigInitError if no configuration could be loaded both locally and remote.
* @throws ConfigInitError if no configuration could be loaded.
* @throws WrongConfigVersionInStorage if fetch failed and saved config has wrong SCVersion
*/
async init(): Promise<void> {
let loadError;
let fetchError;
// load saved configuration
try {
// Attempt to load the configuration from local storage
this.config = await this.loadLocal();
this.firstSession = false;
this.logger.log(`initialised configuration from storage`);
// Check if the stored configuration has the correct version
if (this.config.backend.SCVersion.split('.')[0] !== this.scVersion.split('.')[0]) {
throw new WrongConfigVersionInStorage(this.scVersion, this.config.backend.SCVersion);
loadError = new WrongConfigVersionInStorage(this.scVersion, this.config.backend.SCVersion);
}
// Fetch the remote configuration in a non-blocking manner
void this.fetch();
} catch (loadError) {
} catch (error) {
loadError = error;
}
// fetch remote configuration from backend
try {
const fetchedConfig: SCIndexResponse = await this.fetch();
await this.set(fetchedConfig);
this.logger.log(`initialised configuration from remote`);
} catch (error) {
fetchError = error;
}
// check for occurred errors and throw them
if (loadError !== undefined && fetchError !== undefined) {
throw new ConfigInitError();
}
if (loadError !== undefined) {
this.logger.warn(loadError);
try {
// If local loading fails, immediately try to fetch the configuration from remote
await this.fetch();
} catch (fetchError) {
this.logger.warn(`Failed to fetch remote configuration:`, fetchError);
// If both local loading and remote fetching fail, throw ConfigInitError
throw new ConfigInitError();
}
}
if (fetchError !== undefined) {
this.logger.warn(fetchError);
}
}

View File

@@ -24,6 +24,7 @@ import {
SCSearchQuery,
SCSearchSort,
SCThings,
SCSearchSuggestions,
} from '@openstapps/core';
import {NGXLogger} from 'ngx-logger';
import {combineLatest, Subject} from 'rxjs';
@@ -110,6 +111,8 @@ export class SearchPageComponent implements OnInit {
*/
items: Promise<SCThings[]>;
suggestions: SCSearchSuggestions | undefined;
/**
* Page size of queries
*/
@@ -219,6 +222,7 @@ export class SearchPageComponent implements OnInit {
try {
const result = await this.dataProvider.search(searchOptions);
this.suggestions = result.suggestions;
this.singleTypeResponse = result.facets.find(facet => facet.field === 'type')?.buckets.length === 1;
if (append) {
// append results
@@ -283,6 +287,12 @@ export class SearchPageComponent implements OnInit {
this.contextMenuService.updateContextFilter(facets);
}
applySuggestion(target: string, suggestion: string) {
this.queryText = this.queryText.replaceAll(target, suggestion);
this.suggestions = undefined;
this.searchStringChanged(this.queryText);
}
ngOnInit(defaultListeners = true) {
this.initialize();
this.contextMenuService.setContextSort({

View File

@@ -69,7 +69,23 @@
</ion-header>
<ion-content class="content">
<div class="suggestions">
@if (suggestions?.terms; as terms) {
<span>{{ 'search.SUGGESTIONS' | translate }}: </span>
@for (suggestion of terms | keyvalue; track suggestion) {
@for (term of suggestion.value; track term) {
@if ($index == 0) {
<b (click)="applySuggestion(suggestion.key, term)" class="suggestion">{{ term }}</b>
} @else {
<span (click)="applySuggestion(suggestion.key, term)" class="suggestion">{{ term }}</span>
}
}
}
}
</div>
<div
class="hint"
[class.no-results]="!showDefaultData && !items && !loading"
[style.display]="!showDefaultData && !items && !loading ? 'block' : 'none'"
>

View File

@@ -46,7 +46,7 @@ ion-content {
--background: var(--ion-background-color);
}
.content > div {
.content > .hint {
height: 100%;
ion-label.centered-message-container {
@@ -60,3 +60,19 @@ ion-content {
ion-header {
background: var(--ion-color-primary);
}
.suggestions {
padding: var(--spacing-md);
padding-block-end: 0;
}
.suggestion {
cursor: pointer;
}
.suggestion + .suggestion::before {
cursor: text;
content: ',';
padding-inline-end: 0.25ch;
font-weight: normal;
}

View File

@@ -80,12 +80,13 @@
</ion-item>
<ion-item>
<ion-checkbox
class="ion-text-wrap"
color="primary"
label-placement="end"
justify="start"
[(ngModel)]="termsAgree"
name="termsAgree"
><span class="ion-text-wrap">{{ 'feedback.form.termsAgree.0' | translate }}</span></ion-checkbox
>{{ 'feedback.form.termsAgree.0' | translate }}</ion-checkbox
>
</ion-item>
<ion-item lines="none">
@@ -103,9 +104,7 @@
justify="start"
[(ngModel)]="protocolDataAgree"
name="protocolDataAgree"
><span class="ion-text-wrap">{{
'feedback.form.protocolDataAgree' | translate
}}</span></ion-checkbox
>{{ 'feedback.form.protocolDataAgree' | translate }}</ion-checkbox
>
</ion-item>
<ion-card>

View File

@@ -41,7 +41,7 @@ export class IdCardsProvider {
mergeMap(user => this.fetchFallbackIdCards(user)),
startWith([]),
)
: of([]).pipe(tap({next: () => this.encryptedStorageProvider.delete('id-cards')})),
: of([]).pipe(tap(() => this.encryptedStorageProvider.delete('id-cards'))),
),
);
}
@@ -54,7 +54,7 @@ export class IdCardsProvider {
},
responseType: 'json',
})
.pipe(tap({next: idCards => this.encryptedStorageProvider.set('id-cards', idCards)}));
.pipe(tap(idCards => this.encryptedStorageProvider.set('id-cards', idCards)));
}
private fetchFallbackIdCards(user: SCUserConfiguration): Observable<SCIdCard[]> {

View File

@@ -422,7 +422,8 @@
"placeholder": "Veranstaltungen, Personen, Orte und mehr"
},
"instruction": "Finde alle Informationen rund ums Studium und den Campus",
"nothing_found": "Keine Ergebnisse"
"nothing_found": "Keine Ergebnisse",
"SUGGESTIONS": "Meintest du"
},
"hebisSearch": {
"title": "Bibliothekssuche",

View File

@@ -422,7 +422,8 @@
"placeholder": "Events, places, persons and more"
},
"instruction": "Find all information related to your studies and campus",
"nothing_found": "No results"
"nothing_found": "No results",
"SUGGESTIONS": "Did you mean"
},
"hebisSearch": {
"title": "Library Search",

View File

@@ -18,7 +18,7 @@
// The list of which env maps to which file can be found in `.angular-cli.json`.
export const environment = {
backend_url: 'https://mobile.server.uni-frankfurt.de',
backend_url: 'http://localhost:3000',
app_host: 'mobile.app.uni-frankfurt.de',
custom_url_scheme: 'de.anyschool.app',
backend_version: '999.0.0',

View File

@@ -23,7 +23,7 @@ node ./lib/cli.js e2e http://localhost:3000
Example to clone the full database
```shell
node app.js copy "*" https://mobile.app.uni-frankfurt.de http://localhost:3000 100
node app.js copy "*" -a "999.0.0" https://mobile.server.uni-frankfurt.de http://localhost:3000 100
```
### Program arguments

View File

@@ -97,6 +97,8 @@
"date",
"validatable",
"filterable",
"suggestable",
"completable",
"inheritTags",
"minLength",
"pattern",

View File

@@ -24,6 +24,11 @@ export interface SCSearchResult {
*/
data: SCThings[];
/**
* Suggestions for query corrections
*/
suggestions?: SCSearchSuggestions;
/**
* Facets (aggregations over all matching data)
*/
@@ -40,6 +45,18 @@ export interface SCSearchResult {
stats: SCSearchResultSearchEngineStats;
}
/**
* Seach suggestions
*
* Not to be confused with search-as-you-type suggestions
*/
export interface SCSearchSuggestions {
/**
* Suggestions for query terms that might have been misspelled
*/
terms?: Record<string, string[]>;
}
/**
* Stores information about Pagination
*/

View File

@@ -63,7 +63,7 @@ export interface SCThingWithoutReferences {
/**
* Alternate names of the thing
* @filterable
* @keyword
* @text
*/
alternateNames?: string[];
@@ -92,6 +92,8 @@ export interface SCThingWithoutReferences {
* @filterable
* @minLength 1
* @sortable ducet
* @completable
* @suggestable
* @text
*/
name: string;
@@ -240,6 +242,8 @@ export interface SCThingTranslatableProperties {
* Translation of the name of the thing
* @sortable ducet
* @text
* @suggestable
* @completable
*/
name?: string;
/**

View File

@@ -43,6 +43,27 @@ export const fieldmap: ElasticsearchFieldmap = {
},
ignore: ['price'],
},
suggestable: {
default: {
trigram: {
type: 'text',
analyzer: 'trigram',
},
reverse: {
type: 'text',
analyzer: 'reverse',
},
},
ignore: [],
},
completable: {
default: {
completion: {
type: 'search_as_you_type',
},
},
ignore: [],
},
};
export const filterableTagName = 'filterable';

View File

@@ -19,4 +19,27 @@ export const settings: IndicesPutTemplateRequest['settings'] = {
'max_result_window': 30_000,
'number_of_replicas': 0,
'number_of_shards': 1,
'index': {
analysis: {
analyzer: {
trigram: {
type: 'custom',
tokenizer: 'standard',
filter: ['lowercase', 'shingle'],
},
reverse: {
type: 'custom',
tokenizer: 'standard',
filter: ['lowercase', 'reverse'],
},
},
filter: {
shingle: {
type: 'shingle',
min_shingle_size: 2,
max_shingle_size: 3,
},
},
},
},
};

65
pnpm-lock.yaml generated
View File

@@ -837,8 +837,8 @@ importers:
specifier: 0.9.0
version: 0.9.0(rxjs@7.8.1)
jsonpath-plus:
specifier: 10.0.6
version: 10.0.6
specifier: 6.0.1
version: 6.0.1
maplibre-gl:
specifier: 4.0.2
version: 4.0.2
@@ -5522,7 +5522,7 @@ packages:
object-assign: 4.1.1
open: 8.4.0
proxy-middleware: 0.15.0
send: 1.1.0
send: 0.18.0
serve-index: 1.9.1
transitivePeerDependencies:
- supports-color
@@ -6971,24 +6971,6 @@ packages:
'@jridgewell/resolve-uri': 3.1.1
'@jridgewell/sourcemap-codec': 1.4.15
/@jsep-plugin/assignment@1.2.1(jsep@1.3.9):
resolution: {integrity: sha512-gaHqbubTi29aZpVbBlECRpmdia+L5/lh2BwtIJTmtxdbecEyyX/ejAOg7eQDGNvGOUmPY7Z2Yxdy9ioyH/VJeA==}
engines: {node: '>= 10.16.0'}
peerDependencies:
jsep: ^0.4.0||^1.0.0
dependencies:
jsep: 1.3.9
dev: false
/@jsep-plugin/regex@1.0.3(jsep@1.3.9):
resolution: {integrity: sha512-XfZgry4DwEZvSFtS/6Y+R48D7qJYJK6R9/yJFyUFHCIUMEEHuJ4X95TDgJp5QkmzfLYvapMPzskV5HpIDrREug==}
engines: {node: '>= 10.16.0'}
peerDependencies:
jsep: ^0.4.0||^1.0.0
dependencies:
jsep: 1.3.9
dev: false
/@leichtgewicht/ip-codec@2.0.5:
resolution: {integrity: sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==}
dev: true
@@ -11984,11 +11966,6 @@ packages:
resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==}
engines: {node: '>= 0.8'}
/encodeurl@2.0.0:
resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==}
engines: {node: '>= 0.8'}
dev: true
/encoding@0.1.13:
resolution: {integrity: sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==}
requiresBuild: true
@@ -14943,11 +14920,6 @@ packages:
resolution: {integrity: sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==}
engines: {node: '>=12.0.0'}
/jsep@1.3.9:
resolution: {integrity: sha512-i1rBX5N7VPl0eYb6+mHNp52sEuaS2Wi8CDYx1X5sn9naevL78+265XJqy1qENEk7mRKwS06NHpUqiBwR7qeodw==}
engines: {node: '>= 10.16.0'}
dev: false
/jsesc@0.5.0:
resolution: {integrity: sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==}
hasBin: true
@@ -15039,14 +15011,9 @@ packages:
engines: {'0': node >= 0.2.0}
dev: true
/jsonpath-plus@10.0.6:
resolution: {integrity: sha512-Q0KCash90S0WQnPnE/W0uVXQSww4NkO34COfs+gbq0fk+Kv03FYpZ+uU2I7soLLaS4d/ywsm9PxplZsTMmfBmg==}
engines: {node: '>=18.0.0'}
hasBin: true
dependencies:
'@jsep-plugin/assignment': 1.2.1(jsep@1.3.9)
'@jsep-plugin/regex': 1.0.3(jsep@1.3.9)
jsep: 1.3.9
/jsonpath-plus@6.0.1:
resolution: {integrity: sha512-EvGovdvau6FyLexFH2OeXfIITlgIbgZoAZe3usiySeaIDm5QS+A10DKNpaPBBqqRSZr2HN6HVNXxtwUAr2apEw==}
engines: {node: '>=10.0.0'}
dev: false
/jsonpointer@5.0.1:
@@ -18961,26 +18928,6 @@ packages:
transitivePeerDependencies:
- supports-color
/send@1.1.0:
resolution: {integrity: sha512-v67WcEouB5GxbTWL/4NeToqcZiAWEq90N888fczVArY8A79J0L4FD7vj5hm3eUMua5EpoQ59wa/oovY6TLvRUA==}
engines: {node: '>= 18'}
dependencies:
debug: 4.3.6(supports-color@8.1.1)
destroy: 1.2.0
encodeurl: 2.0.0
escape-html: 1.0.3
etag: 1.8.1
fresh: 0.5.2
http-errors: 2.0.0
mime-types: 2.1.35
ms: 2.1.3
on-finished: 2.4.1
range-parser: 1.2.1
statuses: 2.0.1
transitivePeerDependencies:
- supports-color
dev: true
/serialize-javascript@6.0.0:
resolution: {integrity: sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==}
dependencies: