Skip to content

Commit

Permalink
Merge pull request #408 from geonetwork/exclude-map
Browse files Browse the repository at this point in the history
Elasticsearch: Exclude map resourceTypes
  • Loading branch information
tkohr authored Jan 11, 2023
2 parents 4f05914 + 03ebb84 commit 22d8aca
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ describe('ElasticsearchService', () => {
isTemplate: ['n'],
},
},
{
terms: {
resourceType: [
'dataset',
'series',
'publication',
'nonGeographicDataset',
],
},
},
{
query_string: {
default_operator: 'AND',
Expand All @@ -107,11 +117,6 @@ describe('ElasticsearchService', () => {
},
},
],
must_not: {
terms: {
resourceType: ['service', 'featureCatalog'],
},
},
},
})
})
Expand All @@ -136,6 +141,16 @@ describe('ElasticsearchService', () => {
isTemplate: ['n'],
},
},
{
terms: {
resourceType: [
'dataset',
'series',
'publication',
'nonGeographicDataset',
],
},
},
{
query_string: {
default_operator: 'AND',
Expand All @@ -161,11 +176,6 @@ describe('ElasticsearchService', () => {
},
},
],
must_not: {
terms: {
resourceType: ['service', 'featureCatalog'],
},
},
},
})
})
Expand All @@ -181,7 +191,7 @@ describe('ElasticsearchService', () => {
)
})
it('escapes special char', () => {
expect(query.bool.must[1].query_string.query).toEqual(
expect(query.bool.must[2].query_string.query).toEqual(
`scot \\(\\)\\{\\?\\[ \\/ test`
)
})
Expand Down Expand Up @@ -231,6 +241,16 @@ describe('ElasticsearchService', () => {
isTemplate: ['n'],
},
},
{
terms: {
resourceType: [
'dataset',
'series',
'publication',
'nonGeographicDataset',
],
},
},
{
query_string: {
default_operator: 'AND',
Expand All @@ -251,11 +271,6 @@ describe('ElasticsearchService', () => {
},
},
],
must_not: {
terms: {
resourceType: ['service', 'featureCatalog'],
},
},
should: [
{
geo_shape: {
Expand Down Expand Up @@ -339,6 +354,16 @@ describe('ElasticsearchService', () => {
isTemplate: ['n'],
},
},
{
terms: {
resourceType: [
'dataset',
'series',
'publication',
'nonGeographicDataset',
],
},
},
{
multi_match: {
fields: [
Expand All @@ -352,11 +377,6 @@ describe('ElasticsearchService', () => {
},
},
],
must_not: {
terms: {
resourceType: ['service', 'featureCatalog'],
},
},
},
},
from: 0,
Expand Down
32 changes: 15 additions & 17 deletions libs/util/shared/src/lib/elasticsearch/elasticsearch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,17 @@ export class ElasticsearchService {
geometry?: Geometry
) {
const queryFilters = this.stateFiltersToQueryString(fieldSearchFilters)
const must = [this.queryFilterOnValues('isTemplate', 'n')] as Record<
string,
unknown
>[]
const must = [
this.queryFilterOnValues('isTemplate', 'n'),
this.queryFilterOnValues('resourceType', [
'dataset',
'series',
'publication',
'nonGeographicDataset',
]),
] as Record<string, unknown>[]
const should = [] as Record<string, unknown>[]
const filter = this.buildPayloadFilter(configFilters)
const must_not = {
...this.queryFilterOnValues('resourceType', [
'service',
'featureCatalog',
]),
}

if (any) {
must.push({
Expand Down Expand Up @@ -188,7 +187,6 @@ export class ElasticsearchService {
return {
bool: {
must,
must_not,
should,
filter,
},
Expand Down Expand Up @@ -242,6 +240,12 @@ export class ElasticsearchService {
bool: {
must: [
this.queryFilterOnValues('isTemplate', 'n'),
this.queryFilterOnValues('resourceType', [
'dataset',
'series',
'publication',
'nonGeographicDataset',
]),
{
multi_match: {
query,
Expand All @@ -258,12 +262,6 @@ export class ElasticsearchService {
},
},
],
must_not: {
...this.queryFilterOnValues('resourceType', [
'service',
'featureCatalog',
]),
},
},
},
_source: ['resourceTitleObject', 'uuid'],
Expand Down
3 changes: 3 additions & 0 deletions tailwind.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ module.exports = {
opacity: {
45: 0.45,
},
boxShadow: {
'xl-hover': '0 20px 25px -5px rgb(0 0 0 / 0.2)',
},
},
},
plugins: [require('@tailwindcss/line-clamp')],
Expand Down

0 comments on commit 22d8aca

Please sign in to comment.