Skip to content
Snippets Groups Projects
Commit 4b79bbf3 authored by Matthieu Benoist's avatar Matthieu Benoist
Browse files

Add a post_filter for all scopes on ES request to exclude the pages from the search.

parent af2b03a5
Branches
Tags
1 merge request!110Add a post_filter for all scopes on ES request to exclude the pages from the search.
...@@ -513,19 +513,18 @@ export class ElasticsearchService { ...@@ -513,19 +513,18 @@ export class ElasticsearchService {
requestOptions.body.query.bool['must'] = mustExpression; requestOptions.body.query.bool['must'] = mustExpression;
// Filter by scope (dataset, service, post, page). If the scope is 'all', we don't apply any filter // Filter by scope (dataset, service, post, page). If the scope is 'all', we don't apply any filter
if (options.scope.key !== scopesResearch.all.key) { const filtersScope = [];
const filtersScope = []; options.scope.elasticType.forEach((type) => {
options.scope.elasticType.forEach((type) => { filtersScope.push(type);
filtersScope.push(type); });
}); // For the scopes we use post_filter instead of filter.
// For the scopes we use post_filter instead of filter. // The difference is that the aggregations will be calculated before this filter is applied.
// The difference is that the aggregations will be calculated before this filter is applied. requestOptions.body['post_filter'] = {
requestOptions.body['post_filter'] = { terms: {
terms: { 'type.keyword': filtersScope,
'type.keyword': filtersScope, },
}, };
};
}
// Aggregations for the filter options // Aggregations for the filter options
// We have different filters determined by 'index' property. // We have different filters determined by 'index' property.
......
...@@ -4,7 +4,7 @@ export const scopesResearch = { ...@@ -4,7 +4,7 @@ export const scopesResearch = {
all: { all: {
key: 'all', key: 'all',
label: geosource.researchScope.all, label: geosource.researchScope.all,
elasticType: [''], elasticType: ['dataset', 'nonGeographicDataset', 'series', 'nonGeographicSeries','service','post'],
errorItem: geosource.errorItem.all, errorItem: geosource.errorItem.all,
}, },
datasets: datasets:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment