diff --git a/src/app/geosource/services/elasticsearch.service.ts b/src/app/geosource/services/elasticsearch.service.ts index 2b2ff4d273e7d7573dbd5a4a93c7a7c60a9d19a6..cab37974091ddcc1ae1eb47787111178990cc0b3 100644 --- a/src/app/geosource/services/elasticsearch.service.ts +++ b/src/app/geosource/services/elasticsearch.service.ts @@ -283,8 +283,8 @@ export class ElasticsearchService { } /* - * This request will get one suggestion from the query text - * The suggest is based on metadata-fr.title property + * This request will get one phrase suggestion out of the query text + * cf. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html */ getSuggestion(query: string): Observable<SearchSuggestion> { return this._http.request<IElasticsearchResponse>('POST', this.url, { @@ -293,16 +293,20 @@ export class ElasticsearchService { text: query, suggestion: { phrase: { - field: 'data_and_metadata', + field: 'data_and_metadata.suggest', + // as only the very first suggestion will be used, let's limit the size of the results to 1: + size: 1, + max_errors: query.split(' ').length, highlight: { pre_tag: '<b><i>', post_tag: '</i></b>', }, + analyzer: 'my_search_analyzer', direct_generator: [{ - field: 'data_and_metadata', - suggest_mode: 'popular', - // prefix_length: 4, - min_word_length: 1, + field: 'data_and_metadata.suggest', + suggest_mode: 'missing', + prefix_length: 1, + min_word_length: 4, }], }, }, diff --git a/src/environments/environment.ts b/src/environments/environment.ts index f32fb6a47b50e6cd4d6aa32e2f22449193910f1b..57e69081b41ca4fdf3bb728acb7e3f2b4b87e308 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -11,7 +11,7 @@ export const environment = { // ElasticSearch elasticsearchUrl: { - full: servicesProxyUrl + '/elasticsearch2/test-all-in-one-index.full.v8.quadtree', + full: servicesProxyUrl + '/elasticsearch2/test-all-in-one-index.full.v9.quadtree', meta: servicesProxyUrl + '/elasticsearch/*.meta', },