Skip to content

Commit

Permalink
Merge pull request #26 from eea/develop
Browse files Browse the repository at this point in the history
New globalsearchbase config
  • Loading branch information
tiberiuichim authored Mar 1, 2023
2 parents 31cf8e1 + f702851 commit 69edaed
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 117 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [1.0.12](https://github.com/eea/volto-globalsearch/compare/1.0.11...1.0.12) - 1 March 2023

#### :hammer_and_wrench: Others

- Prettier [Tiberiu Ichim - [`d2fced6`](https://github.com/eea/volto-globalsearch/commit/d2fced6fb614b7b2dca3ff1425ce33400a085a5d)]
- removed unused imports [Zoltan Szabo - [`f6d7dc4`](https://github.com/eea/volto-globalsearch/commit/f6d7dc4f787005027a102fb513aa2e8aba5ffba9)]
- Added 'Publication reference' to the 'Others' cluster [Zoltan Szabo - [`73e289d`](https://github.com/eea/volto-globalsearch/commit/73e289deb8e841610575ff92095506b7279ecbc5)]
- Refs #241801; Added searchengine with new facet for keywords [Zoltan Szabo - [`654f3ca`](https://github.com/eea/volto-globalsearch/commit/654f3ca1ba79190c721bf200f24808b31c79be8f)]
### [1.0.11](https://github.com/eea/volto-globalsearch/compare/1.0.10...1.0.11) - 14 February 2023

#### :hammer_and_wrench: Others
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-globalsearch",
"version": "1.0.11",
"version": "1.0.12",
"description": "@eeacms/volto-globalsearch: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
1 change: 1 addition & 0 deletions src/config/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const clusters = {
'Tool',
'Case study',
'External data reference',
'Publication reference',
], // this will be transformed in "single type clusters".
defaultResultView: 'horizontalCard',
},
Expand Down
9 changes: 9 additions & 0 deletions src/config/facets.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ const facets = [
showAllOptions: true, // show all options (even if 0) in modal facet
alwaysVisible: true,
}),
multiTermFacet({
field: 'subject.keyword',
isFilterable: true,
isMulti: true,
label: 'Keywords',
show: 10000,
showAllOptions: true, // show all options (even if 0) in modal facet
alwaysVisible: false,
}),
multiTermFacet({
field: 'spatial',
isFilterable: true,
Expand Down
120 changes: 120 additions & 0 deletions src/config/global-search-base-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import { build_runtime_mappings } from '../utils';
import clusterParams, { clusters } from './clusters';

import facets from './facets';
import views from './views';
import query from './query';
import filters from './filters';
import download from './download';
import vocabs from './vocabulary';

import objectProvidesWhitelist from './json/objectProvidesWhitelist.json';
import spatialWhitelist from './json/spatialWhitelist.json';
import placesBlacklist from './json/placesBlacklist.json';
import typesWhitelist from './json/typesWhitelist.json';

const globalSearchBaseConfig = {
title: 'Global search and catalogue',
layoutComponent: 'TopFilterLayout',
contentBodyComponent: 'FilterAsideContentView',
enableNLP: true, // enables NLP capabilities
facetsListComponent: 'DropdownFacetsList',
runtime_mappings: build_runtime_mappings(clusters),
useSearchPhrases: false,
searchAsYouType: false,
landingPageURL: '/en/advanced-search',
getActiveFilters: 'getGlobalSearchActiveFilters',

...vocabs,
...facets,
...views,
...query,
...filters,
...download,
...clusterParams,

sourceExcludedFields: ['embedding'], // don't need these in results
// 'fulltext',

// these are used to "clean" the values in the results.
field_filters: {
type: {
whitelist: typesWhitelist,
},
objectProvides: {
whitelist: objectProvidesWhitelist,
},
spatial: {
whitelist: spatialWhitelist,
},
places: {
blacklist: placesBlacklist,
},
},

highlight: {
queryParams: {
fragment_size: 200,
number_of_fragments: 3,
},
fields: ['description.highlight'],
queryBuilder: {
factory: 'highlightQueryBuilder',
},
},

sortOptions: [
{
name: 'Title a-z',
value: 'title.index',
direction: 'asc',
},
{
name: 'Title z-a',
value: 'title.index',
direction: 'desc',
},
{
name: 'Oldest',
value: 'issued.date',
direction: 'asc',
},
{
name: 'Newest',
value: 'issued.date',
direction: 'desc',
},
],

defaultPromptQueries: [
'what is the status of our forests',
'what is PFAS?',
'how does PFAS get into human?',
'what is the cumulative surface area of the Natura 2000?',
'what percentage of europe population is connected to waste water treatement?',
'How is the status of fish species in Europe?',
'What is the BISE?',
'how much does transport contributes to GHG emissions in EU?',
'Which cities in Europe have the worst air quality?',
'What car is best for the environment?',
'What transport mode is best for the environment?',
'What EU legislation safeguards our water?',
'What is land accounting?',
'What countries had the highest land take in the EEA-39 between 2000 and 2018?',
'Why is urban sprawl bad?',
'what are controlled substances',
'what is plastic',
'What year did car manufacturers meet their binding emissions target?',
'What is the percentage of surface water bodies with less than good status?',
'What is the most common pollutant in water bodies in Europe?',
'Where can I access greenhouse gas data',
'What is the trend on greenhouse gas emissions from transport',
'what is the best transport mode',
'what are ecosystem services',
'bathing water quality',
'greenhouse gas emissions trends',
'waste generation trends',
],
};

export default globalSearchBaseConfig;
121 changes: 6 additions & 115 deletions src/config/global-search-config.js
Original file line number Diff line number Diff line change
@@ -1,120 +1,11 @@
import { build_runtime_mappings } from '../utils';
import clusterParams, { clusters } from './clusters';
import cloneDeep from 'lodash.clonedeep';

import facets from './facets';
import views from './views';
import query from './query';
import filters from './filters';
import download from './download';
import vocabs from './vocabulary';
import globalSearchBaseConfig from './global-search-base-config.js';

import objectProvidesWhitelist from './json/objectProvidesWhitelist.json';
import spatialWhitelist from './json/spatialWhitelist.json';
import placesBlacklist from './json/placesBlacklist.json';
import typesWhitelist from './json/typesWhitelist.json';
let globalSearchConfig = cloneDeep(globalSearchBaseConfig);

const globalSearchConfig = {
title: 'Global search and catalogue',
layoutComponent: 'TopFilterLayout',
contentBodyComponent: 'FilterAsideContentView',
enableNLP: true, // enables NLP capabilities
facetsListComponent: 'DropdownFacetsList',
runtime_mappings: build_runtime_mappings(clusters),
useSearchPhrases: false,
searchAsYouType: false,
landingPageURL: '/en/advanced-search',
getActiveFilters: 'getGlobalSearchActiveFilters',

...vocabs,
...facets,
...views,
...query,
...filters,
...download,
...clusterParams,

sourceExcludedFields: ['embedding'], // don't need these in results
// 'fulltext',

// these are used to "clean" the values in the results.
field_filters: {
type: {
whitelist: typesWhitelist,
},
objectProvides: {
whitelist: objectProvidesWhitelist,
},
spatial: {
whitelist: spatialWhitelist,
},
places: {
blacklist: placesBlacklist,
},
},

highlight: {
queryParams: {
fragment_size: 200,
number_of_fragments: 3,
},
fields: ['description.highlight'],
queryBuilder: {
factory: 'highlightQueryBuilder',
},
},

sortOptions: [
{
name: 'Title a-z',
value: 'title.index',
direction: 'asc',
},
{
name: 'Title z-a',
value: 'title.index',
direction: 'desc',
},
{
name: 'Oldest',
value: 'issued.date',
direction: 'asc',
},
{
name: 'Newest',
value: 'issued.date',
direction: 'desc',
},
],

defaultPromptQueries: [
'what is the status of our forests',
'what is PFAS?',
'how does PFAS get into human?',
'what is the cumulative surface area of the Natura 2000?',
'what percentage of europe population is connected to waste water treatement?',
'How is the status of fish species in Europe?',
'What is the BISE?',
'how much does transport contributes to GHG emissions in EU?',
'Which cities in Europe have the worst air quality?',
'What car is best for the environment?',
'What transport mode is best for the environment?',
'What EU legislation safeguards our water?',
'What is land accounting?',
'What countries had the highest land take in the EEA-39 between 2000 and 2018?',
'Why is urban sprawl bad?',
'what are controlled substances',
'what is plastic',
'What year did car manufacturers meet their binding emissions target?',
'What is the percentage of surface water bodies with less than good status?',
'What is the most common pollutant in water bodies in Europe?',
'Where can I access greenhouse gas data',
'What is the trend on greenhouse gas emissions from transport',
'what is the best transport mode',
'what are ecosystem services',
'bathing water quality',
'greenhouse gas emissions trends',
'waste generation trends',
],
};
globalSearchConfig.facets = globalSearchConfig.facets.filter(
(facet) => facet['field'] !== 'subject.keyword',
);

export default globalSearchConfig;
7 changes: 7 additions & 0 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { UniversalCard } from '@eeacms/volto-listing-block';
import contentTypeNormalize from './json/contentTypeNormalize.json';
import globalSearchConfig from './global-search-config.js';

import globalSearchBaseConfig from './global-search-base-config.js';

const getClientProxyAddress = () => {
const url = new URL(window.location);
url.pathname = '';
Expand Down Expand Up @@ -67,6 +69,11 @@ export default function install(config) {
host: process.env.RAZZLE_ES_PROXY_ADDR || 'http://localhost:3000',
};

config.searchui.globalsearchbase = {
...mergeConfig(globalSearchBaseConfig, config.searchui.default),
elastic_index: 'es',
host: process.env.RAZZLE_ES_PROXY_ADDR || 'http://localhost:3000',
};
if (typeof window !== 'undefined') {
config.searchui.globalsearch.host =
process.env.RAZZLE_ES_PROXY_ADDR || getClientProxyAddress();
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import installGlobalsearch from './config';
export default (config) => {
config.settings.searchlib = installGlobalsearch(config.settings.searchlib);

const { globalsearch } = config.settings.searchlib.searchui;
const { globalsearch, globalsearchbase } = config.settings.searchlib.searchui;

// Tweak the searchlib config to use the middleware instead of the index
globalsearch.elastic_index = '_es/globalsearch';
globalsearch.index_name = 'data_searchui';

globalsearchbase.elastic_index = '_es/globalsearch';
globalsearchbase.index_name = 'data_searchui';

return config;
};

0 comments on commit 69edaed

Please sign in to comment.