From 59e16b83a0ab91b8be7009abcaf8e595955c5d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Prunayre?= Date: Tue, 20 May 2014 18:55:26 +0200 Subject: [PATCH] Suggestion / Add the possibility to have a search field on a specific lucene field and the suggestion list based on another field. The main idea is to restrict the list of possibilities for a full text field which will suggest numbers, uuids, filepath fragments, ... which could be complex to understand for the end-user. In that case, a new field nammed anylight is created only indexing title, abstracts, keywords from which the suggestion will come from for the full text search field. --- .../geonet/kernel/search/LuceneSearcher.java | 2 +- .../form/OpenSearchSuggestionTextField.js | 10 +++++++- .../src/main/resources/apps/search/js/App.js | 1 + web/src/main/webapp/WEB-INF/config-lucene.xml | 1 + .../schema_plugins/iso19139/index-fields.xsl | 25 ++++++++++++++++--- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/fao/geonet/kernel/search/LuceneSearcher.java b/core/src/main/java/org/fao/geonet/kernel/search/LuceneSearcher.java index 479f1d4cc09..ed0da2cb906 100644 --- a/core/src/main/java/org/fao/geonet/kernel/search/LuceneSearcher.java +++ b/core/src/main/java/org/fao/geonet/kernel/search/LuceneSearcher.java @@ -623,7 +623,7 @@ private void computeQuery(ServiceContext srvContext, Element request, ServiceCon String[] items = summaryItemsEl.getValue().split(","); for (String item : items) { - if (item.equals("any")) { + if (item.startsWith("any")) { tmpConfig = _summaryConfig; break; } diff --git a/web-client/src/main/resources/apps/js/GeoNetwork/lib/GeoNetwork/form/OpenSearchSuggestionTextField.js b/web-client/src/main/resources/apps/js/GeoNetwork/lib/GeoNetwork/form/OpenSearchSuggestionTextField.js index 5c2141c8280..b90468e49bc 100644 --- a/web-client/src/main/resources/apps/js/GeoNetwork/lib/GeoNetwork/form/OpenSearchSuggestionTextField.js +++ b/web-client/src/main/resources/apps/js/GeoNetwork/lib/GeoNetwork/form/OpenSearchSuggestionTextField.js @@ -82,6 +82,14 @@ GeoNetwork.form.OpenSearchSuggestionTextField = Ext.extend(Ext.form.ComboBox, { * Default any (ie. full text search). */ field: 'any', + /** api: config[suggestionField] + * ``String`` Optional, GeoNetwork Lucene field to use for suggestion. + * If undefined, field is used. That could be useful to restrict the suggestion + * to a subset of values for this field. For example any match any text + * in a metadata record, but suggestion could be limited to title, abstract, keywords + * stored in the anylight field. + */ + suggestionField: '', /** api: config[fieldName] * ``String`` Optional, Field name. */ @@ -155,7 +163,7 @@ GeoNetwork.form.OpenSearchSuggestionTextField = Ext.extend(Ext.form.ComboBox, { url: this.url, rootId: 1, baseParams: { - field: this.field, + field: this.suggestionField || this.field, // withFrequency: true, // To display frequency info sortBy: this.sortBy } diff --git a/web-client/src/main/resources/apps/search/js/App.js b/web-client/src/main/resources/apps/search/js/App.js index d90c3d35356..cce04b7086f 100644 --- a/web-client/src/main/resources/apps/search/js/App.js +++ b/web-client/src/main/resources/apps/search/js/App.js @@ -336,6 +336,7 @@ GeoNetwork.app = function () { new GeoNetwork.form.OpenSearchSuggestionTextField({ hideLabel: true, minChars: 2, + suggestionField: 'anylight', loadingText: '...', hideTrigger: true, url: catalogue.services.opensearchSuggest diff --git a/web/src/main/webapp/WEB-INF/config-lucene.xml b/web/src/main/webapp/WEB-INF/config-lucene.xml index e5764b2ebe7..9606e4f4ef9 100644 --- a/web/src/main/webapp/WEB-INF/config-lucene.xml +++ b/web/src/main/webapp/WEB-INF/config-lucene.xml @@ -276,6 +276,7 @@ --> + diff --git a/web/src/main/webapp/WEB-INF/data/config/schema_plugins/iso19139/index-fields.xsl b/web/src/main/webapp/WEB-INF/data/config/schema_plugins/iso19139/index-fields.xsl index 6e73ede1b25..638f77786c4 100644 --- a/web/src/main/webapp/WEB-INF/data/config/schema_plugins/iso19139/index-fields.xsl +++ b/web/src/main/webapp/WEB-INF/data/config/schema_plugins/iso19139/index-fields.xsl @@ -130,7 +130,6 @@ - @@ -180,7 +179,7 @@ - + @@ -694,7 +693,27 @@ - + + + + + + + + + + +