geonetwork-ui 2.11.0-dev.ca7fb6b05 → 2.11.0-dev.d02d7f3f8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/geonetwork-ui.mjs +2058 -1186
- package/fesm2022/geonetwork-ui.mjs.map +1 -1
- package/index.d.ts +386 -139
- package/index.d.ts.map +1 -1
- package/package.json +7 -5
- package/src/libs/api/metadata-converter/src/lib/dcat-ap/dcat-ap.converter.ts +2 -0
- package/src/libs/api/metadata-converter/src/lib/fixtures/mel.records.dataset+featurecatalog.ts +395 -0
- package/src/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts +35 -8
- package/src/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts +19 -0
- package/src/libs/api/metadata-converter/src/lib/iso19115-3/iso19115-3.converter.ts +17 -6
- package/src/libs/api/metadata-converter/src/lib/iso19115-3/read-parts.ts +110 -0
- package/src/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.ts +131 -0
- package/src/libs/api/metadata-converter/src/lib/iso19139/iso19139.converter.ts +9 -0
- package/src/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts +2 -1
- package/src/libs/api/repository/src/lib/gn4/elasticsearch/constant.ts +4 -0
- package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +174 -55
- package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +82 -35
- package/src/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts +11 -0
- package/src/libs/common/domain/src/lib/model/record/flags.model.ts +1 -0
- package/src/libs/common/domain/src/lib/model/record/index.ts +1 -0
- package/src/libs/common/domain/src/lib/model/record/metadata.model.ts +14 -18
- package/src/libs/common/domain/src/lib/model/search/aggregation.model.ts +2 -0
- package/src/libs/common/domain/src/lib/model/search/filter.model.ts +24 -2
- package/src/libs/common/domain/src/lib/platform.service.interface.ts +1 -0
- package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +20 -1
- package/src/libs/common/fixtures/src/lib/records.fixtures.ts +42 -62
- package/src/libs/feature/dataviz/src/lib/service/data.service.ts +32 -19
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-constraints/form-field-constraints.component.ts +3 -5
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-contacts/form-field-contacts.component.ts +2 -2
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.html +18 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.ts +86 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +100 -88
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +11 -4
- package/src/libs/feature/editor/src/lib/components/record-form/record-form.component.ts +18 -4
- package/src/libs/feature/editor/src/lib/expressions.ts +67 -0
- package/src/libs/feature/editor/src/lib/fields.config.ts +13 -0
- package/src/libs/feature/editor/src/lib/models/editor-config.model.ts +10 -4
- package/src/libs/feature/map/src/index.ts +0 -2
- package/src/libs/feature/map/src/lib/add-layer-from-file/add-layer-from-file.component.html +1 -0
- package/src/libs/feature/map/src/lib/feature-map.module.ts +1 -8
- package/src/libs/feature/notifications/src/lib/notifications.service.ts +6 -4
- package/src/libs/feature/notify-reuse/src/lib/notify-reuse-form/notify-reuse-form.component.ts +8 -3
- package/src/libs/feature/record/src/lib/state/mdview.effects.ts +3 -1
- package/src/libs/feature/record/src/lib/state/mdview.facade.ts +1 -1
- package/src/libs/feature/router/src/lib/default/state/query-params.utils.ts +1 -1
- package/src/libs/feature/search/src/index.ts +2 -0
- package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.html +18 -4
- package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +80 -19
- package/src/libs/feature/search/src/lib/geocoding/geocoding.service.ts +105 -0
- package/src/libs/feature/search/src/lib/location-search/location-search.component.html +18 -0
- package/src/libs/feature/search/src/lib/location-search/location-search.component.ts +114 -0
- package/src/libs/feature/search/src/lib/search-filters-summary-item/search-filters-summary-item.component.ts +19 -8
- package/src/libs/feature/search/src/lib/state/reducer.ts +1 -4
- package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +64 -4
- package/src/libs/feature/search/src/lib/utils/service/fields.ts +94 -10
- package/src/libs/ui/elements/src/lib/kind-badge/kind-badge.component.html +5 -1
- package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.html +3 -3
- package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.ts +2 -2
- package/src/libs/ui/elements/src/lib/service-capabilities/service-capabilities.component.ts +2 -1
- package/src/libs/ui/elements/src/lib/thumbnail/thumbnail.component.html +1 -1
- package/src/libs/ui/inputs/src/index.ts +2 -0
- package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.css +0 -4
- package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.html +12 -3
- package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.ts +11 -3
- package/src/libs/ui/inputs/src/lib/date-adapter.providers.ts +30 -0
- package/src/libs/ui/inputs/src/lib/date-picker/date-picker.component.ts +3 -24
- package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.css +37 -3
- package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.html +135 -16
- package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.ts +166 -29
- package/src/libs/ui/inputs/src/lib/date-range-picker/date-range-picker.component.ts +3 -7
- package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.css +1 -0
- package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.html +20 -7
- package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.ts +46 -5
- package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.html +7 -4
- package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.ts +12 -9
- package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.model.ts +2 -2
- package/src/libs/ui/inputs/src/lib/inline-filter/inline-filter.component.html +6 -11
- package/src/libs/ui/inputs/src/lib/search-feature-catalog/search-feature-catalog.component.ts +2 -1
- package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.css +0 -0
- package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html +117 -0
- package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +244 -0
- package/src/libs/ui/layout/src/lib/block-list/block-list.component.css +1 -0
- package/src/libs/ui/map/src/lib/components/map-container/map-container.component.ts +2 -0
- package/src/libs/ui/search/src/lib/results-hits-number/results-hits-number.component.html +1 -0
- package/src/libs/util/app-config/src/index.ts +1 -0
- package/src/libs/util/app-config/src/lib/app-config.ts +338 -247
- package/src/libs/util/app-config/src/lib/fixtures.ts +37 -1
- package/src/libs/util/app-config/src/lib/model.ts +42 -1
- package/src/libs/util/app-config/src/lib/parse-utils.ts +8 -4
- package/src/libs/util/shared/src/index.ts +1 -0
- package/src/libs/util/shared/src/lib/autofocus.directive.ts +26 -0
- package/src/libs/util/shared/src/lib/links/link-utils.ts +19 -10
- package/src/libs/util/shared/src/lib/services/date.service.ts +3 -3
- package/src/libs/util/shared/src/lib/utils/file.ts +15 -0
- package/src/libs/util/shared/src/lib/utils/geojson.ts +45 -10
- package/src/libs/util/shared/src/lib/utils/index.ts +1 -0
- package/tailwind.base.css +5 -0
- package/translations/de.json +28 -4
- package/translations/en.json +27 -3
- package/translations/es.json +26 -2
- package/translations/fr.json +32 -8
- package/translations/it.json +26 -2
- package/translations/nl.json +26 -2
- package/translations/pt.json +26 -2
- package/translations/sk.json +26 -2
- package/src/libs/feature/map/src/lib/geocoding/geocoding.component.html +0 -41
- package/src/libs/feature/map/src/lib/geocoding/geocoding.component.ts +0 -112
- package/src/libs/feature/map/src/lib/geocoding.service.ts +0 -57
- package/src/libs/feature/map/src/lib/style/index.ts +0 -2
- package/src/libs/feature/map/src/lib/style/map-style.fixtures.ts +0 -47
- package/src/libs/feature/map/src/lib/style/map-style.service.ts +0 -108
- /package/src/libs/feature/{map/src/lib/geocoding/geocoding.component.css → editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.css} +0 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CatalogRecord,
|
|
3
|
+
DatasetFeatureAttribute,
|
|
4
|
+
DatasetFeatureAttributeValue,
|
|
5
|
+
DatasetFeatureType,
|
|
3
6
|
DatasetRecord,
|
|
4
7
|
Individual,
|
|
5
8
|
LanguageCode,
|
|
@@ -616,3 +619,131 @@ export function writeAssociatedRecords(
|
|
|
616
619
|
)
|
|
617
620
|
)(rootEl)
|
|
618
621
|
}
|
|
622
|
+
|
|
623
|
+
function createNilElement(name: string, nilReason: string) {
|
|
624
|
+
return pipe(createElement(name), writeAttribute('gco:nilReason', nilReason))
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function createFeatureCatalogueShell() {
|
|
628
|
+
return pipe(
|
|
629
|
+
createNestedElement(
|
|
630
|
+
'mdb:contentInfo',
|
|
631
|
+
'mrc:MD_FeatureCatalogue',
|
|
632
|
+
'mrc:featureCatalogue',
|
|
633
|
+
'gfc:FC_FeatureCatalogue'
|
|
634
|
+
),
|
|
635
|
+
// create mandatory elements which are not part of the model yet
|
|
636
|
+
appendChildren(
|
|
637
|
+
createNilElement('cat:name', 'missing'),
|
|
638
|
+
createNilElement('cat:scope', 'missing'),
|
|
639
|
+
createNilElement('cat:versionNumber', 'missing'),
|
|
640
|
+
createNilElement('cat:versionDate', 'missing'),
|
|
641
|
+
createNilElement('gfc:producer', 'missing')
|
|
642
|
+
)
|
|
643
|
+
)
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
function createListedValue(value: DatasetFeatureAttributeValue) {
|
|
647
|
+
return pipe(
|
|
648
|
+
createNestedElement('gfc:listedValue', 'gfc:FC_ListedValue'),
|
|
649
|
+
appendChildren(
|
|
650
|
+
value.label
|
|
651
|
+
? pipe(createElement('gfc:label'), writeCharacterString(value.label))
|
|
652
|
+
: createNilElement('gfc:label', 'missing'),
|
|
653
|
+
value.value
|
|
654
|
+
? pipe(createElement('gfc:code'), writeCharacterString(value.value))
|
|
655
|
+
: null,
|
|
656
|
+
value.description
|
|
657
|
+
? pipe(
|
|
658
|
+
createElement('gfc:definition'),
|
|
659
|
+
writeCharacterString(value.description)
|
|
660
|
+
)
|
|
661
|
+
: null
|
|
662
|
+
)
|
|
663
|
+
)
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
function createFeatureAttribute(attribute: DatasetFeatureAttribute) {
|
|
667
|
+
return pipe(
|
|
668
|
+
createNestedElement(
|
|
669
|
+
'gfc:carrierOfCharacteristics',
|
|
670
|
+
'gfc:FC_FeatureAttribute'
|
|
671
|
+
),
|
|
672
|
+
appendChildren(
|
|
673
|
+
pipe(createElement('gfc:memberName'), setTextContent(attribute.name)),
|
|
674
|
+
attribute.description
|
|
675
|
+
? pipe(
|
|
676
|
+
createElement('gfc:definition'),
|
|
677
|
+
writeCharacterString(attribute.description)
|
|
678
|
+
)
|
|
679
|
+
: null,
|
|
680
|
+
createNilElement('gfc:cardinality', 'missing'),
|
|
681
|
+
attribute.label
|
|
682
|
+
? pipe(
|
|
683
|
+
createElement('gfc:designation'),
|
|
684
|
+
writeCharacterString(attribute.label)
|
|
685
|
+
)
|
|
686
|
+
: null,
|
|
687
|
+
attribute.code
|
|
688
|
+
? pipe(createElement('gfc:code'), writeCharacterString(attribute.code))
|
|
689
|
+
: null,
|
|
690
|
+
attribute.type
|
|
691
|
+
? pipe(
|
|
692
|
+
createNestedElement('gfc:valueType', 'gco:TypeName', 'gco:aName'),
|
|
693
|
+
writeCharacterString(attribute.type)
|
|
694
|
+
)
|
|
695
|
+
: null,
|
|
696
|
+
...(attribute.values ?? [])
|
|
697
|
+
.filter((value) => value.value || value.label)
|
|
698
|
+
.map(createListedValue)
|
|
699
|
+
)
|
|
700
|
+
)
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
function createFeatureType(featureType: DatasetFeatureType) {
|
|
704
|
+
return pipe(
|
|
705
|
+
createNestedElement('gfc:featureType', 'gfc:FC_FeatureType'),
|
|
706
|
+
appendChildren(
|
|
707
|
+
pipe(createElement('gfc:typeName'), setTextContent(featureType.name)),
|
|
708
|
+
featureType.description
|
|
709
|
+
? pipe(
|
|
710
|
+
createElement('gfc:definition'),
|
|
711
|
+
writeCharacterString(featureType.description)
|
|
712
|
+
)
|
|
713
|
+
: null,
|
|
714
|
+
pipe(
|
|
715
|
+
createNestedElement('gfc:isAbstract', 'gco:Boolean'),
|
|
716
|
+
setTextContent('false')
|
|
717
|
+
),
|
|
718
|
+
featureType.label
|
|
719
|
+
? pipe(
|
|
720
|
+
createElement('gfc:designation'),
|
|
721
|
+
writeCharacterString(featureType.label)
|
|
722
|
+
)
|
|
723
|
+
: null,
|
|
724
|
+
...featureType.attributes.map(createFeatureAttribute),
|
|
725
|
+
createNilElement('gfc:featureCatalogue', 'missing')
|
|
726
|
+
)
|
|
727
|
+
)
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
export function writeFeatureTypeDescriptions(
|
|
731
|
+
record: DatasetRecord,
|
|
732
|
+
rootEl: XmlElement
|
|
733
|
+
) {
|
|
734
|
+
const featureTypes = record.featureTypeDescriptions ?? []
|
|
735
|
+
const catalogues = findNestedElements(
|
|
736
|
+
'mdb:contentInfo',
|
|
737
|
+
'mrc:MD_FeatureCatalogue',
|
|
738
|
+
'mrc:featureCatalogue',
|
|
739
|
+
'gfc:FC_FeatureCatalogue'
|
|
740
|
+
)(rootEl)
|
|
741
|
+
catalogues.forEach((catalogue) =>
|
|
742
|
+
removeChildrenByName('gfc:featureType')(catalogue)
|
|
743
|
+
)
|
|
744
|
+
if (!featureTypes.length) return
|
|
745
|
+
|
|
746
|
+
const catalogue =
|
|
747
|
+
catalogues[0] ?? appendChildTree(createFeatureCatalogueShell())(rootEl)
|
|
748
|
+
appendChildren(...featureTypes.map(createFeatureType))(catalogue)
|
|
749
|
+
}
|
|
@@ -118,6 +118,7 @@ export class Iso19139Converter extends BaseConverter<string> {
|
|
|
118
118
|
lineage: readLineage,
|
|
119
119
|
sourceRecords: readSourceRecords,
|
|
120
120
|
associatedRecords: readAssociatedRecords,
|
|
121
|
+
featureTypeDescriptions: () => undefined,
|
|
121
122
|
onlineResources: readOnlineResources,
|
|
122
123
|
temporalExtents: readTemporalExtents,
|
|
123
124
|
spatialExtents: readSpatialExtents,
|
|
@@ -161,6 +162,7 @@ export class Iso19139Converter extends BaseConverter<string> {
|
|
|
161
162
|
lineage: writeLineage,
|
|
162
163
|
sourceRecords: writeSourceRecords,
|
|
163
164
|
associatedRecords: writeAssociatedRecords,
|
|
165
|
+
featureTypeDescriptions: () => undefined,
|
|
164
166
|
onlineResources: writeOnlineResources,
|
|
165
167
|
temporalExtents: writeTemporalExtents,
|
|
166
168
|
spatialExtents: writeSpatialExtents,
|
|
@@ -306,6 +308,10 @@ export class Iso19139Converter extends BaseConverter<string> {
|
|
|
306
308
|
const sourceRecords = this.readers['sourceRecords'](rootEl, tr)
|
|
307
309
|
const associatedRecords = this.readers['associatedRecords'](rootEl, tr)
|
|
308
310
|
const updateFrequency = this.readers['updateFrequency'](rootEl, tr)
|
|
311
|
+
const featureTypeDescriptions = this.readers['featureTypeDescriptions'](
|
|
312
|
+
rootEl,
|
|
313
|
+
tr
|
|
314
|
+
) as DatasetRecord['featureTypeDescriptions']
|
|
309
315
|
|
|
310
316
|
return this.afterRecordRead({
|
|
311
317
|
...this.readBaseRecord(rootEl, tr),
|
|
@@ -317,6 +323,7 @@ export class Iso19139Converter extends BaseConverter<string> {
|
|
|
317
323
|
...(spatialRepresentation && { spatialRepresentation }),
|
|
318
324
|
temporalExtents,
|
|
319
325
|
updateFrequency,
|
|
326
|
+
...(featureTypeDescriptions?.length && { featureTypeDescriptions }),
|
|
320
327
|
translations: tr,
|
|
321
328
|
} as DatasetRecord)
|
|
322
329
|
} else if (kind === 'reuse') {
|
|
@@ -416,6 +423,8 @@ export class Iso19139Converter extends BaseConverter<string> {
|
|
|
416
423
|
|
|
417
424
|
if (record.kind === 'dataset') {
|
|
418
425
|
fieldChanged('status') && this.writers['status'](record, rootEl)
|
|
426
|
+
fieldChanged('featureTypeDescriptions') &&
|
|
427
|
+
this.writers['featureTypeDescriptions'](record, rootEl)
|
|
419
428
|
}
|
|
420
429
|
if (record.kind === 'dataset' || record.kind === 'reuse') {
|
|
421
430
|
fieldChanged('updateFrequency') &&
|
|
@@ -69,7 +69,8 @@ export function extractCharacterString(): ChainableFunction<
|
|
|
69
69
|
fallback(
|
|
70
70
|
findChildElement('gco:CharacterString', false),
|
|
71
71
|
findChildElement('gmx:Anchor', false),
|
|
72
|
-
findChildElement('gmx:MimeFileType', false)
|
|
72
|
+
findChildElement('gmx:MimeFileType', false),
|
|
73
|
+
findChildElement('gco:LocalName', false)
|
|
73
74
|
),
|
|
74
75
|
readText()
|
|
75
76
|
)
|
|
@@ -31,3 +31,7 @@ export const ES_QUERY_FIELDS_PRIORITY = {
|
|
|
31
31
|
'any.${searchLang}': 1,
|
|
32
32
|
uuid: 1,
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
// This prefix is part of the category names stored in GeoNetwork: changing it
|
|
36
|
+
// would silently drop the flags already set on existing catalogs.
|
|
37
|
+
export const RECORD_FLAG_CATEGORY_PREFIX = 'geonetwork-ui-flag:'
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ES_QUERY_FIELDS_PRIORITY,
|
|
5
5
|
ES_SOURCE_SUMMARY,
|
|
6
6
|
EsQueryFieldsPriorityType,
|
|
7
|
+
RECORD_FLAG_CATEGORY_PREFIX,
|
|
7
8
|
} from './constant'
|
|
8
9
|
import {
|
|
9
10
|
Aggregation,
|
|
@@ -34,12 +35,19 @@ import {
|
|
|
34
35
|
LanguageCode,
|
|
35
36
|
} from '../../../../../../../libs/common/domain/src/lib/model/record'
|
|
36
37
|
import { TranslateService } from '@ngx-translate/core'
|
|
37
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
bboxToGeometry,
|
|
40
|
+
BoundingBox,
|
|
41
|
+
getGeometryBoundingBox,
|
|
42
|
+
isBoundingBox,
|
|
43
|
+
} from '../../../../../../../libs/util/shared/src'
|
|
38
44
|
import { getLength as getGeodesicLength } from 'ol/sphere.js'
|
|
39
45
|
import { LineString } from 'ol/geom.js'
|
|
40
46
|
|
|
41
47
|
export type DateRange = { start?: Date; end?: Date }
|
|
42
48
|
|
|
49
|
+
export const REFERENCE_DATASET_BOOST = 5
|
|
50
|
+
|
|
43
51
|
@Injectable({
|
|
44
52
|
providedIn: 'root',
|
|
45
53
|
})
|
|
@@ -49,7 +57,12 @@ export class ElasticsearchService {
|
|
|
49
57
|
|
|
50
58
|
// runtime fields are computed using a Painless script
|
|
51
59
|
// see: https://www.elastic.co/guide/en/elasticsearch/reference/current/runtime-mapping-fields.html
|
|
52
|
-
private runtimeFields: Record<
|
|
60
|
+
private runtimeFields: Record<
|
|
61
|
+
string,
|
|
62
|
+
{ script: string; type: 'keyword' | 'date' }
|
|
63
|
+
> = {}
|
|
64
|
+
|
|
65
|
+
private fieldAliases: Record<string, string> = {}
|
|
53
66
|
|
|
54
67
|
// we're using getters in case the defined languages change over time
|
|
55
68
|
private get metadataLang(): LanguageCode {
|
|
@@ -91,8 +104,8 @@ export class ElasticsearchService {
|
|
|
91
104
|
const addMapping = (fieldName: string) => {
|
|
92
105
|
if (!payload.runtime_mappings) payload.runtime_mappings = {}
|
|
93
106
|
payload.runtime_mappings[fieldName] = {
|
|
94
|
-
type:
|
|
95
|
-
script: this.runtimeFields[fieldName],
|
|
107
|
+
type: this.runtimeFields[fieldName].type,
|
|
108
|
+
script: this.runtimeFields[fieldName].script,
|
|
96
109
|
}
|
|
97
110
|
}
|
|
98
111
|
const lookForField = (node: unknown) => {
|
|
@@ -113,6 +126,14 @@ export class ElasticsearchService {
|
|
|
113
126
|
) {
|
|
114
127
|
addMapping(runtimeField)
|
|
115
128
|
}
|
|
129
|
+
if (
|
|
130
|
+
runtimeField in node &&
|
|
131
|
+
typeof node[runtimeField] === 'object' &&
|
|
132
|
+
node[runtimeField] !== null &&
|
|
133
|
+
('gte' in node[runtimeField] || 'lte' in node[runtimeField])
|
|
134
|
+
) {
|
|
135
|
+
addMapping(runtimeField)
|
|
136
|
+
}
|
|
116
137
|
if (
|
|
117
138
|
'query' in node &&
|
|
118
139
|
typeof node.query === 'string' &&
|
|
@@ -131,8 +152,16 @@ export class ElasticsearchService {
|
|
|
131
152
|
return payload
|
|
132
153
|
}
|
|
133
154
|
|
|
134
|
-
registerRuntimeField(
|
|
135
|
-
|
|
155
|
+
registerRuntimeField(
|
|
156
|
+
fieldName: string,
|
|
157
|
+
expression: string,
|
|
158
|
+
type: 'keyword' | 'date' = 'keyword'
|
|
159
|
+
) {
|
|
160
|
+
this.runtimeFields[fieldName] = { script: expression, type }
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
registerFieldAlias(fieldIdentifier: string, esFieldName: string) {
|
|
164
|
+
this.fieldAliases[fieldIdentifier] = esFieldName
|
|
136
165
|
}
|
|
137
166
|
|
|
138
167
|
getMetadataByIdsPayload(uuids: string[]): EsSearchParams {
|
|
@@ -264,8 +293,68 @@ export class ElasticsearchService {
|
|
|
264
293
|
return this.metadataLang === 'current'
|
|
265
294
|
}
|
|
266
295
|
|
|
267
|
-
private
|
|
296
|
+
private findSpatialFilterExtent(
|
|
268
297
|
filters: FieldFilters | FiltersAggregationParams | string
|
|
298
|
+
): BoundingBox | undefined {
|
|
299
|
+
if (typeof filters === 'string') {
|
|
300
|
+
return undefined
|
|
301
|
+
}
|
|
302
|
+
return Object.values(filters).find(isBoundingBox)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// builds a query matching records whose dates intersect the filter range
|
|
306
|
+
private buildDateRangeQuery(searchField: string, dateRange: DateRange) {
|
|
307
|
+
// fields ending with 'DateRange' maps as ES range type
|
|
308
|
+
if (searchField.endsWith('DateRange')) {
|
|
309
|
+
return {
|
|
310
|
+
range: {
|
|
311
|
+
[searchField]: {
|
|
312
|
+
...(dateRange.start && { gte: formatDate(dateRange.start) }),
|
|
313
|
+
...(dateRange.end && { lte: formatDate(dateRange.end) }),
|
|
314
|
+
format: 'yyyy-MM-dd',
|
|
315
|
+
relation: 'intersects',
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const minField = `${searchField}Min`
|
|
321
|
+
const maxField = `${searchField}Max`
|
|
322
|
+
if (minField in this.runtimeFields && maxField in this.runtimeFields) {
|
|
323
|
+
// min/max runtime fields form an interval per record; match if it intersects the filter range
|
|
324
|
+
const filter = [
|
|
325
|
+
dateRange.start && {
|
|
326
|
+
range: {
|
|
327
|
+
[maxField]: {
|
|
328
|
+
gte: formatDate(dateRange.start),
|
|
329
|
+
format: 'yyyy-MM-dd',
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
dateRange.end && {
|
|
334
|
+
range: {
|
|
335
|
+
[minField]: {
|
|
336
|
+
lte: formatDate(dateRange.end),
|
|
337
|
+
format: 'yyyy-MM-dd',
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
].filter(Boolean)
|
|
342
|
+
return { bool: { filter } }
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
range: {
|
|
346
|
+
[searchField]: {
|
|
347
|
+
...(dateRange.start && { gte: formatDate(dateRange.start) }),
|
|
348
|
+
...(dateRange.end && { lte: formatDate(dateRange.end) }),
|
|
349
|
+
format: 'yyyy-MM-dd',
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private filtersToQuery(
|
|
356
|
+
filters: FieldFilters | FiltersAggregationParams | string,
|
|
357
|
+
spatialFilterExtent = this.findSpatialFilterExtent(filters)
|
|
269
358
|
): FilterQuery {
|
|
270
359
|
const addQuote = (key: string) => (/^\/.+\/$/.test(key) ? key : `"${key}"`)
|
|
271
360
|
const makeQuery = (filter: FieldFilter): string => {
|
|
@@ -286,50 +375,49 @@ export class ElasticsearchService {
|
|
|
286
375
|
? filters
|
|
287
376
|
: Object.keys(filters)
|
|
288
377
|
.filter((fieldname) => fieldname !== 'gn-ui-crossFieldFilter')
|
|
378
|
+
.filter((fieldname) => !isBoundingBox(filters[fieldname]))
|
|
289
379
|
.filter((fieldname) => !isDateRange(filters[fieldname]))
|
|
380
|
+
.filter((fieldname) => !Array.isArray(filters[fieldname]))
|
|
290
381
|
.filter(
|
|
291
382
|
(fieldname) =>
|
|
292
383
|
filters[fieldname] &&
|
|
293
384
|
JSON.stringify(filters[fieldname]) !== '{}'
|
|
294
385
|
)
|
|
295
386
|
.map(
|
|
296
|
-
(fieldname) =>
|
|
387
|
+
(fieldname) =>
|
|
388
|
+
`${this.fieldAliases[fieldname] ?? fieldname}:(${makeQuery(filters[fieldname])})`
|
|
297
389
|
)
|
|
298
390
|
.join(' AND ')
|
|
299
391
|
if (filters['gn-ui-crossFieldFilter']) {
|
|
300
392
|
queryString = `${queryString} AND (${filters['gn-ui-crossFieldFilter']})`
|
|
301
393
|
}
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return {
|
|
306
|
-
searchField,
|
|
307
|
-
dateRange,
|
|
308
|
-
} as {
|
|
309
|
-
searchField: string
|
|
310
|
-
dateRange: DateRange
|
|
311
|
-
}
|
|
312
|
-
})[0]
|
|
394
|
+
const queryRanges = Object.entries(filters).filter(([, value]) =>
|
|
395
|
+
isDateRange(value)
|
|
396
|
+
) as [string, DateRange][]
|
|
313
397
|
const queryParts = [
|
|
314
398
|
queryString && {
|
|
315
399
|
query_string: {
|
|
316
400
|
query: queryString,
|
|
317
401
|
},
|
|
318
402
|
},
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
403
|
+
...queryRanges.map(([searchField, dateRange]) =>
|
|
404
|
+
this.buildDateRangeQuery(searchField, dateRange)
|
|
405
|
+
),
|
|
406
|
+
spatialFilterExtent && {
|
|
407
|
+
geo_shape: {
|
|
408
|
+
geom: {
|
|
409
|
+
shape: {
|
|
410
|
+
type: 'envelope',
|
|
411
|
+
// spatialFilterExtent is [minX, minY, maxX, maxY]; envelope coordinates are [top-left, bottom-right]
|
|
412
|
+
coordinates: [
|
|
413
|
+
[spatialFilterExtent[0], spatialFilterExtent[3]],
|
|
414
|
+
[spatialFilterExtent[2], spatialFilterExtent[1]],
|
|
415
|
+
],
|
|
330
416
|
},
|
|
417
|
+
relation: 'intersects',
|
|
331
418
|
},
|
|
332
419
|
},
|
|
420
|
+
},
|
|
333
421
|
].filter(Boolean)
|
|
334
422
|
return queryParts.length > 0 ? (queryParts as FilterQuery) : undefined
|
|
335
423
|
}
|
|
@@ -353,7 +441,18 @@ export class ElasticsearchService {
|
|
|
353
441
|
) {
|
|
354
442
|
const must = [] as Record<string, unknown>[]
|
|
355
443
|
const must_not = this.mustNotFilters()
|
|
356
|
-
const should = [
|
|
444
|
+
const should = [
|
|
445
|
+
{
|
|
446
|
+
constant_score: {
|
|
447
|
+
filter: {
|
|
448
|
+
term: {
|
|
449
|
+
'cat.keyword': `${RECORD_FLAG_CATEGORY_PREFIX}IS_REFERENCE_DATASET`,
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
boost: REFERENCE_DATASET_BOOST,
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
] as Record<string, unknown>[]
|
|
357
456
|
const filter = [this.queryFilterOnValues('isTemplate', 'n')] as Record<
|
|
358
457
|
string,
|
|
359
458
|
unknown
|
|
@@ -368,7 +467,12 @@ export class ElasticsearchService {
|
|
|
368
467
|
},
|
|
369
468
|
})
|
|
370
469
|
}
|
|
371
|
-
|
|
470
|
+
// a spatial extent filter takes precedence over the preference geometry for boosting
|
|
471
|
+
const spatialFilterExtent = this.findSpatialFilterExtent(fieldSearchFilters)
|
|
472
|
+
const queryFilters = this.filtersToQuery(
|
|
473
|
+
fieldSearchFilters,
|
|
474
|
+
spatialFilterExtent
|
|
475
|
+
)
|
|
372
476
|
if (queryFilters) {
|
|
373
477
|
filter.push(...queryFilters)
|
|
374
478
|
}
|
|
@@ -379,37 +483,43 @@ export class ElasticsearchService {
|
|
|
379
483
|
},
|
|
380
484
|
})
|
|
381
485
|
}
|
|
382
|
-
|
|
486
|
+
const boostGeometry = spatialFilterExtent
|
|
487
|
+
? bboxToGeometry(spatialFilterExtent)
|
|
488
|
+
: geometry
|
|
489
|
+
if (boostGeometry) {
|
|
383
490
|
// boosts applied using the filter geometry:
|
|
384
491
|
// * records completely within the geometry receive a boost of 5
|
|
385
492
|
// * records intersecting the geometry receive a boost of 2
|
|
386
493
|
// * records close to the geometry center receive a boost of 5 (based on the `location` field)
|
|
387
494
|
// * records on the outskirt of the geometry receive a boost of 2.5
|
|
388
|
-
|
|
389
|
-
|
|
495
|
+
if (
|
|
496
|
+
boostGeometry.type === 'Polygon' ||
|
|
497
|
+
boostGeometry.type === 'MultiPolygon'
|
|
498
|
+
) {
|
|
499
|
+
should.push({
|
|
390
500
|
geo_shape: {
|
|
391
501
|
geom: {
|
|
392
|
-
shape:
|
|
502
|
+
shape: boostGeometry,
|
|
393
503
|
relation: 'within',
|
|
394
504
|
},
|
|
395
505
|
boost: 5.0,
|
|
396
506
|
},
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
boost: 2.0,
|
|
507
|
+
})
|
|
508
|
+
}
|
|
509
|
+
should.push({
|
|
510
|
+
geo_shape: {
|
|
511
|
+
geom: {
|
|
512
|
+
shape: boostGeometry,
|
|
513
|
+
relation: 'intersects',
|
|
405
514
|
},
|
|
406
|
-
|
|
407
|
-
|
|
515
|
+
boost: 2.0,
|
|
516
|
+
},
|
|
517
|
+
})
|
|
408
518
|
|
|
409
519
|
// this will boost the results variably depending on their distance from the given geometry
|
|
410
520
|
// note: this takes into account the `location` field of a record; this is generally the center of all spatial extents
|
|
411
521
|
// combined, and thus the actual size/coverage of the record spatial extent isn't relevant here
|
|
412
|
-
const bbox = getGeometryBoundingBox(
|
|
522
|
+
const bbox = getGeometryBoundingBox(boostGeometry)
|
|
413
523
|
const center = [(bbox[0] + bbox[2]) / 2, (bbox[1] + bbox[3]) / 2]
|
|
414
524
|
const northToCenter = new LineString([
|
|
415
525
|
[center[0], bbox[3]],
|
|
@@ -435,15 +545,18 @@ export class ElasticsearchService {
|
|
|
435
545
|
getGeodesicLength(westToCenter) +
|
|
436
546
|
getGeodesicLength(eastToCenter)) /
|
|
437
547
|
4
|
|
548
|
+
const pivot = Math.round(cutoffDistance)
|
|
438
549
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
550
|
+
if (pivot > 0) {
|
|
551
|
+
should.push({
|
|
552
|
+
distance_feature: {
|
|
553
|
+
field: 'location',
|
|
554
|
+
pivot: `${pivot.toFixed(0)}m`,
|
|
555
|
+
origin: center,
|
|
556
|
+
boost: 5.0,
|
|
557
|
+
},
|
|
558
|
+
})
|
|
559
|
+
}
|
|
447
560
|
}
|
|
448
561
|
|
|
449
562
|
return {
|
|
@@ -635,6 +748,12 @@ export class ElasticsearchService {
|
|
|
635
748
|
order: {
|
|
636
749
|
[`_${aggregation.sort[1]}`]: aggregation.sort[0],
|
|
637
750
|
},
|
|
751
|
+
...(aggregation.includeValues && {
|
|
752
|
+
include: aggregation.includeValues,
|
|
753
|
+
}),
|
|
754
|
+
...(aggregation.excludeValues && {
|
|
755
|
+
exclude: aggregation.excludeValues,
|
|
756
|
+
}),
|
|
638
757
|
},
|
|
639
758
|
}
|
|
640
759
|
case 'histogram':
|