Skip to content
Snippets Groups Projects
Commit 430586c9 authored by Alessandro Cerioni's avatar Alessandro Cerioni
Browse files

Improved phrase suggestion.

parent 68c021e7
No related branches found
No related tags found
No related merge requests found
...@@ -283,8 +283,8 @@ export class ElasticsearchService { ...@@ -283,8 +283,8 @@ export class ElasticsearchService {
} }
/* /*
* This request will get one suggestion from the query text * This request will get one phrase suggestion out of the query text
* The suggest is based on metadata-fr.title property * cf. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html
*/ */
getSuggestion(query: string): Observable<SearchSuggestion> { getSuggestion(query: string): Observable<SearchSuggestion> {
return this._http.request<IElasticsearchResponse>('POST', this.url, { return this._http.request<IElasticsearchResponse>('POST', this.url, {
...@@ -293,16 +293,20 @@ export class ElasticsearchService { ...@@ -293,16 +293,20 @@ export class ElasticsearchService {
text: query, text: query,
suggestion: { suggestion: {
phrase: { 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: { highlight: {
pre_tag: '<b><i>', pre_tag: '<b><i>',
post_tag: '</i></b>', post_tag: '</i></b>',
}, },
analyzer: 'my_search_analyzer',
direct_generator: [{ direct_generator: [{
field: 'data_and_metadata', field: 'data_and_metadata.suggest',
suggest_mode: 'popular', suggest_mode: 'missing',
// prefix_length: 4, prefix_length: 1,
min_word_length: 1, min_word_length: 4,
}], }],
}, },
}, },
......
...@@ -11,7 +11,7 @@ export const environment = { ...@@ -11,7 +11,7 @@ export const environment = {
// ElasticSearch // ElasticSearch
elasticsearchUrl: { 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', meta: servicesProxyUrl + '/elasticsearch/*.meta',
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment