Skip to content

Commit

Permalink
Record view / More like this / Add filter option.
Browse files Browse the repository at this point in the history
Similar records are suggested using a more like this query.
Catalogue administrator may want to customize what is proposed.
eg. exclude obsolete records.

Funded by EEA
  • Loading branch information
fxprunayre committed Oct 15, 2024
1 parent e1fde81 commit 41aa021
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 12 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,23 @@ To add a new configuration, such as for a sub-portal (see [Portal configuration]
- **Search application**: Select this check box to determine whether the search application is visible in the top toolbar. If not set, no link is shown.
- **Application URL**: Define the URL for the search application. In the majority of cases this can be left as the default.
- **Number of records per page**: Define the options to determine the number of records shown per page of results, and the default.
- **Type of facet**: Define the set of search facets should be visible in the search page. The default is `details` but `manager` can be used to show the facets more normally used on the editor page.
- **Default search**: Define a default filter for the search.
- **Facet configuration**: See [Configuring faceted search](../../customizing-application/configuring-faceted-search.md)). The configuration are defined using JSON following Elasticsearch API (See <https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket.html>.

![](img/ui-settings-searchpage.png)

- **Facet field to display using tabs**: This option creates a tab for each configured facet above the search results. This can be used to further narrow down the search results. The list of facet names can be found at <https://github.com/geonetwork/core-geonetwork/blob/master/web/src/main/webapp/WEB-INF/config-summary.xml#L82>. For example, to include the Topic Category filter above the search results, the administrator would add `topicCat` as the facet field to display.
- **List of facets**: This can be used to restrict the facets available for searching. For example, adding `topicCat` to this list would restrict the search options to `Topic Category` only. This can be useful for restricting the search options in a sub-portal or external web application. To add additional facets to the list, select the blue `+` button.
- **Facet field to display using tabs**: This option creates a tab for each configured facet above the search results. This can be used to further narrow down the search results.
- **Filters**: Define additional search criteria added to all searches and again are used primarily for external applications and sub-portals.

![](img/ui-settings-searchpage2.png)

- **Type of sort options**: Define the different ways by which a user can sort a set of search results. The **default sort by option** is shown below. Note that to search for example on `title` in alphabetical order it is necessary to set the order to `reverse`.
- **List of templates for search results**: This section allows the administrator to configure templates for the layout of the search results. The default is `grid` whereas `list` is the default for the editor board.

![](img/ui-settings-searchpage3.png)


- **Similar records** or **More like this**: Define the query used to search for similar records that are displayed at the bottom of the record view.

![](img/morelikethisconfig.png)


- **Default template used for search results**: Define the template page for the search. Generally this can be left as the default.
- **List of formatter for record view**: Determine the formatter used to display the search results. See [Customizing metadata views](../../customizing-application/creating-custom-view.md) for information on creating a new formatter. To add an additional view, click the blue `+` button below the list and provide a name and a URL.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,28 @@
var resourceType = scope.md.resourceType
? scope.md.resourceType[0]
: undefined;
var filter = [];
if (scope.ofSameType && resourceType) {
var mapping = resourceTypeMapping[resourceType];
scope.label = mapping ? mapping.label : resourceType;
query.query.bool.filter = [
{ terms: { resourceType: mapping ? mapping.types : [resourceType] } }
];
filter.push({
terms: { resourceType: mapping ? mapping.types : [resourceType] }
});
}

if (
gnGlobalSettings.gnCfg.mods.search.moreLikeThisFilter &&
gnGlobalSettings.gnCfg.mods.search.moreLikeThisFilter != ""
) {
filter.push({
query_string: {
query: gnGlobalSettings.gnCfg.mods.search.moreLikeThisFilter
}
});
}

if (filter.length > 0) {
query.query.bool.filter = filter;
}

return query;
Expand Down
3 changes: 3 additions & 0 deletions web-ui/src/main/resources/catalog/js/CatController.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@
size: 20
},
moreLikeThisSameType: true,
moreLikeThisFilter:
"-cl_status.key:(obsolete OR historicalArchive OR superseded)",
moreLikeThisConfig: {
more_like_this: {
like: [
Expand Down Expand Up @@ -1244,6 +1246,7 @@
"geocoder",
"disabledTools",
"filters",
"info",
"scoreConfig",
"autocompleteConfig",
"moreLikeThisConfig",
Expand Down
1 change: 1 addition & 0 deletions web-ui/src/main/resources/catalog/locales/en-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@
"ui-mod-header": "Top toolbar",
"ui-mod-footer": "Footer",
"ui-mod-cookieWarning": "Cookie warning",
"ui-mod-directory": "Directory",
"ui-createPageTpl": "New metadata page layout",
"ui-createPageTpl-horizontal": "Horizontal",
"ui-createPageTpl-vertical": "Vertical",
Expand Down
6 changes: 4 additions & 2 deletions web-ui/src/main/resources/catalog/locales/en-v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,14 @@
"dropIndexAndRebuild": "Delete index and reindex",
"rebuildIndexHelp": "While rebuilding index, search may return incomplete results and the CSW GetRecords operation can be disabled (if you selected the option in the settings). Use this function, when catalog traffic is low. It's recommended to rebuild index manually from here when making changes directly in the database. If you change index mapping (cf. <a href='https://github.com/geonetwork/core-geonetwork/blob/es/web/src/main/webResources/WEB-INF/data/config/index/records.json'>records.json</a>), then you have to click on 'Delete index and reindex'.",
"indexInEsDoneError": "There is an error with the index. See the logs for details",
"indexInEsDone": "The indexing operation was successfull",
"indexInEsDone": "The indexing operation was successful",
"indexCommit": "Commit index changes",
"indexCommit-help": "To use only if indexing task is hanging.",
"indexCommitError": "Error while committing index changes.",
"ui-moreLikeThisConfig": "More like this configuration",
"ui-moreLikeThisConfig-help": "Configuration must have a more_like_this.like which will be set with the record title to search for similar records.",
"ui-moreLikeThisConfig-help": "Configuration must have a more_like_this.like which will be set with the record title to search for similar records. (See <a href=\"https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html\">Elasticsearch API</a>).",
"ui-moreLikeThisFilter": "More like this query filter",
"ui-moreLikeThisFilter-help": "Optional filter expression to apply on the more like this query (eg. <pre>-cl_status.key:(obsolete OR historicalArchive OR superseded)</pre> to exclude obsolete records).",
"ui-autocompleteConfig": "Autocompletion configuration",
"ui-autocompleteConfig-help": "Configuration must have a query.multi_match.query which will be set on autocompletion.",
"ui-facetConfig": "Facets configuration",
Expand Down

0 comments on commit 41aa021

Please sign in to comment.