Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[DS-1246] Discovery indexer indexes collection license field. #118

Merged
merged 1 commit into from

2 participants

Kevin Van de Velde Mark Diggory
Kevin Van de Velde
Owner

Added configuration for community/collection/item metadata, by default the license field will not be indexed for communities and collections.

Kevin Van de Velde KevinVdV [DS-1246] Discovery indexer indexes collection license field.
Added configuration for community/collection/item metadata, by default the license field will not be indexed for communities and collections.
36554dc
Mark Diggory mdiggory merged commit aa62323 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 30, 2012
  1. Kevin Van de Velde

    [DS-1246] Discovery indexer indexes collection license field.

    KevinVdV authored
    Added configuration for community/collection/item metadata, by default the license field will not be indexed for communities and collections.
This page is out of date. Refresh to see the latest.
5 dspace-api/src/main/java/org/dspace/discovery/SearchUtils.java
View
@@ -67,6 +67,11 @@ public static DiscoveryConfigurationService getConfigurationService() {
return manager.getServiceByName(DiscoveryConfigurationService.class.getName(), DiscoveryConfigurationService.class);
}
+ public static List<String> getIgnoredMetadataFields(int type)
+ {
+ return getConfigurationService().getToIgnoreMetadataFields().get(type);
+ }
+
/**
* Method that retrieves a list of all the configuration objects from the given item
* A configuration object can be returned for each parent community/collection
60 dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java
View
@@ -82,7 +82,7 @@
public static final String STORE_SEPARATOR = "\n|||\n";
public static final String VARIANTS_STORE_SEPARATOR = "###";
-
+
/**
* Non-Static CommonsHttpSolrServer for processing indexing events.
*/
@@ -636,11 +636,12 @@ protected void buildDocument(Context context, Community community)
String rights = community.getMetadata("copyright_text");
String title = community.getMetadata("name");
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.description", description);
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.description.abstract", description_abstract);
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.description.tableofcontents", description_table);
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.rights", rights);
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.title", title);
+ List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(community.getType());
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description", description);
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description.abstract", description_abstract);
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description.tableofcontents", description_table);
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.rights", rights);
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.title", title);
//Do any additional indexing, depends on the plugins
List<SolrServiceIndexPlugin> solrServiceIndexPlugins = new DSpace().getServiceManager().getServicesByType(SolrServiceIndexPlugin.class);
@@ -688,13 +689,14 @@ protected void buildDocument(Context context, Collection collection)
String rights_license = collection.getMetadata("license");
String title = collection.getMetadata("name");
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.description", description);
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.description.abstract", description_abstract);
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.description.tableofcontents", description_table);
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.provenance", provenance);
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.rights", rights);
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.rights.license", rights_license);
- addContainerMetadataField(doc, highlightedMetadataFields, "dc.title", title);
+ List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(collection.getType());
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description", description);
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description.abstract", description_abstract);
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description.tableofcontents", description_table);
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.provenance", provenance);
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.rights", rights);
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.rights.license", rights_license);
+ addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.title", title);
//Do any additional indexing, depends on the plugins
@@ -715,14 +717,17 @@ protected void buildDocument(Context context, Collection collection)
* @param metadataField the metadata field added
* @param value the value (can be NULL !)
*/
- protected void addContainerMetadataField(SolrInputDocument doc, List<String> highlightedMetadataFields, String metadataField, String value)
+ protected void addContainerMetadataField(SolrInputDocument doc, List<String> highlightedMetadataFields, List<String> toIgnoreMetadataFields, String metadataField, String value)
{
- if(StringUtils.isNotBlank(value))
+ if(toIgnoreMetadataFields == null || !toIgnoreMetadataFields.contains(metadataField))
{
- doc.addField(metadataField, value);
- if(highlightedMetadataFields.contains(metadataField))
+ if(StringUtils.isNotBlank(value))
{
- doc.addField(metadataField + "_hl", value);
+ doc.addField(metadataField, value);
+ if(highlightedMetadataFields.contains(metadataField))
+ {
+ doc.addField(metadataField + "_hl", value);
+ }
}
}
}
@@ -822,21 +827,7 @@ protected void buildDocument(Context context, Item item)
}
}
- List<String> toIgnoreFields = new ArrayList<String>();
- String ignoreFieldsString = new DSpace().getConfigurationService().getProperty("discovery.index.ignore");
- if(ignoreFieldsString != null)
- {
- if(ignoreFieldsString.contains(","))
- {
- for (int i = 0; i < ignoreFieldsString.split(",").length; i++)
- {
- toIgnoreFields.add(ignoreFieldsString.split(",")[i].trim());
- }
- } else {
- toIgnoreFields.add(ignoreFieldsString);
- }
- }
-
+
List<String> toProjectionFields = new ArrayList<String>();
String projectionFieldsString = new DSpace().getConfigurationService().getProperty("discovery.index.projection");
if(projectionFieldsString != null){
@@ -867,8 +858,9 @@ protected void buildDocument(Context context, Item item)
field += "." + meta.qualifier;
}
+ List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(item.getType());
//We are not indexing provenance, this is useless
- if (toIgnoreFields.contains(field) || toIgnoreFields.contains(unqualifiedField + "." + Item.ANY))
+ if (toIgnoreMetadataFields != null && (toIgnoreMetadataFields.contains(field) || toIgnoreMetadataFields.contains(unqualifiedField + "." + Item.ANY)))
{
continue;
}
9 dspace-api/src/main/java/org/dspace/discovery/configuration/DiscoveryConfigurationService.java
View
@@ -18,6 +18,7 @@
public class DiscoveryConfigurationService {
private Map<String, DiscoveryConfiguration> map;
+ private Map<Integer, List<String>> toIgnoreMetadataFields;
public Map<String, DiscoveryConfiguration> getMap() {
return map;
@@ -27,6 +28,14 @@ public void setMap(Map<String, DiscoveryConfiguration> map) {
this.map = map;
}
+ public Map<Integer, List<String>> getToIgnoreMetadataFields() {
+ return toIgnoreMetadataFields;
+ }
+
+ public void setToIgnoreMetadataFields(Map<Integer, List<String>> toIgnoreMetadataFields) {
+ this.toIgnoreMetadataFields = toIgnoreMetadataFields;
+ }
+
public static void main(String[] args) {
DSpace dspace = new DSpace();
System.out.println(dspace.getServiceManager().getServicesNames().size());
3  dspace/config/modules/discovery.cfg
View
@@ -10,9 +10,6 @@ search.server = http://localhost:8080/solr/search
#Char used to ensure that the sidebar facets are case insensitive
#solr.facets.split.char=\n|||\n
-#All metadata fields that will not end up in the index, this is a comma separated list
-index.ignore=dc.description.provenance
-
# index.ignore-variants = false
# index.ignore-authority = false
index.projection=dc.title,dc.contributor.*,dc.date.issued
53 dspace/config/spring/api/discovery.xml
View
@@ -9,12 +9,15 @@
-->
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-2.5.xsd"
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util-3.0.xsd"
default-autowire-candidates="*Service,*DAO,javax.sql.DataSource">
<context:annotation-config /> <!-- allows us to use spring annotations in beans -->
@@ -44,6 +47,46 @@
<!--<entry key="123456789/7621" value-ref="defaultConfiguration"/>-->
</map>
</property>
+ <property name="toIgnoreMetadataFields">
+ <map>
+ <entry>
+ <key><util:constant static-field="org.dspace.core.Constants.COMMUNITY"/></key>
+ <list>
+ <!--Introduction text-->
+ <!--<value>dc.description</value>-->
+ <!--Short description-->
+ <!--<value>dc.description.abstract</value>-->
+ <!--News-->
+ <!--<value>dc.description.tableofcontents</value>-->
+ <!--Copyright text-->
+ <value>dc.rights</value>
+ <!--Community name-->
+ <!--<value>dc.title</value>-->
+ </list>
+ </entry>
+ <entry>
+ <key><util:constant static-field="org.dspace.core.Constants.COLLECTION"/></key>
+ <list>
+ <!--Introduction text-->
+ <!--<value>dc.description</value>-->
+ <!--Short description-->
+ <!--<value>dc.description.abstract</value>-->
+ <!--News-->
+ <!--<value>dc.description.tableofcontents</value>-->
+ <!--Copyright text-->
+ <value>dc.rights</value>
+ <!--Collection name-->
+ <!--<value>dc.title</value>-->
+ </list>
+ </entry>
+ <entry>
+ <key><util:constant static-field="org.dspace.core.Constants.ITEM"/></key>
+ <list>
+ <value>dc.description.provenance</value>
+ </list>
+ </entry>
+ </map>
+ </property>
</bean>
<!--The default configuration settings for discovery-->
Something went wrong with that request. Please try again.