Commit 6d1bff8f authored by Matthieu Benoist's avatar Matthieu Benoist
Browse files

Reassemble the results to pick up the title first.

parent a94798ae
......@@ -348,6 +348,7 @@ export class DatasetResearchService {
getAutoComplete(text: string): Observable<SearchCompletion[]> {
const options: SearchCompletion[] = [];
const titleOptions : SearchCompletion[] = [];
return this._elasticsearchService.getAutoComplete(text).pipe(
map((e) => {
// We will loop over all the hits, look if an highlight have been found,
......@@ -368,16 +369,28 @@ export class DatasetResearchService {
});
const same = text.toLowerCase() === highlight[key][0].toLowerCase().replace(/<[^>]*>/g, '');;
if (!same && !found && options.length < 5) {
searchOption['text'] = highlight[key][0];
options.push(new SearchCompletion(searchOption));
if (!same && !found ) {
if (key === 'metadata-fr.title' || key === 'content-fr.title') {
searchOption['text'] = highlight[key][0];
titleOptions.push(new SearchCompletion(searchOption));
}
else {
searchOption['text'] = highlight[key][0];
options.push(new SearchCompletion(searchOption));
}
}
});
}
});
}
return options;
const results = titleOptions.concat(options);
if (results.length > 5) {
results.length = 5;
}
return results;
}),
);
}
......
......@@ -204,7 +204,7 @@ export class ElasticsearchService {
query: regex,
fields: [
'metadata-fr.title^7',
'data-fr.properties^3',
'data-fr.properties^4',
'metadata-fr.abstract^6',
'metadata-fr.keyword^5',
'metadata-fr.lineage^4',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment