Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make dataverse alias searchable #5011 #5267

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions conf/solr/7.3.0/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<field name="isHarvested" type="boolean" stored="true" indexed="true" multiValued="false"/>

<field name="dvName" type="text_en" stored="true" indexed="true" multiValued="false"/>
<field name="dvAlias" type="text_en" stored="true" indexed="true" multiValued="false"/>
<field name="dvAffiliation" type="text_en" stored="true" indexed="true" multiValued="false"/>
<field name="dvDescription" type="text_en" stored="true" indexed="true" multiValued="false"/>

Expand Down Expand Up @@ -456,6 +457,7 @@
<copyField source="variableLabel" dest="_text_" maxChars="3000"/>
<!-- Make dataverse subject and affiliation searchable from basic search: https://github.com/IQSS/dataverse/issues/1431 -->
<copyField source="dvSubject" dest="_text_" maxChars="3000"/>
<copyField source="dvAlias" dest="_text_" maxChars="3000"/>
<copyField source="dvAffiliation" dest="_text_" maxChars="3000"/>
<copyField source="dsPersistentId" dest="_text_" maxChars="3000"/>
<!-- copyField commands copy one field to another at the time a document
Expand Down
1 change: 1 addition & 0 deletions doc/release-notes/5011-search-by-dataverse-alias.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Solr schema.xml file must be updated due to the addition of the "dvAlias" field.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class AdvancedSearchPage implements java.io.Serializable {
private Map<Long, List<DatasetFieldType>> metadataFieldMap = new HashMap<>();
private List<DatasetFieldType> metadataFieldList;
private String dvFieldName;
private String dvFieldAlias;
private String dvFieldDescription;
private String dvFieldAffiliation;
private List<String> dvFieldSubject;
Expand Down Expand Up @@ -123,6 +124,9 @@ private String constructDataverseQuery() {
if (StringUtils.isNotBlank(dvFieldName)) {
queryStrings.add(constructQuery(SearchFields.DATAVERSE_NAME, dvFieldName));
}
if (StringUtils.isNotBlank(dvFieldAlias)) {
queryStrings.add(constructQuery(SearchFields.DATAVERSE_ALIAS, dvFieldAlias));
}

if (StringUtils.isNotBlank(dvFieldAffiliation)) {
queryStrings.add(constructQuery(SearchFields.DATAVERSE_AFFILIATION, dvFieldAffiliation));
Expand Down Expand Up @@ -278,6 +282,14 @@ public void setDvFieldName(String dvFieldName) {
this.dvFieldName = dvFieldName;
}

public String getDvFieldAlias() {
return dvFieldAlias;
}

public void setDvFieldAlias(String dvFieldAlias) {
this.dvFieldAlias = dvFieldAlias;
}

public String getDvFieldDescription() {
return dvFieldDescription;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public Future<String> indexDataverse(Dataverse dataverse) {
solrInputDocument.addField(SearchFields.NAME, dataverse.getName());
solrInputDocument.addField(SearchFields.NAME_SORT, dataverse.getName());
solrInputDocument.addField(SearchFields.DATAVERSE_NAME, dataverse.getName());
solrInputDocument.addField(SearchFields.DATAVERSE_ALIAS, dataverse.getAlias());
solrInputDocument.addField(SearchFields.DATAVERSE_CATEGORY, dataverse.getIndexableCategoryName());
if (dataverse.isReleased()) {
solrInputDocument.addField(SearchFields.PUBLICATION_STATUS, PUBLISHED_STRING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public class SearchFields {
public static final String PERSISTENT_URL = "persistentUrl";
public static final String UNF = "unf";
public static final String DATAVERSE_NAME = "dvName";
public static final String DATAVERSE_ALIAS = "dvAlias";
public static final String DATAVERSE_AFFILIATION = "dvAffiliation";
public static final String DATAVERSE_DESCRIPTION = "dvDescription";
public static final String DATAVERSE_CATEGORY = "dvCategory";
Expand Down
10 changes: 10 additions & 0 deletions src/main/webapp/search/advanced.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
<p:inputText id="dvFieldName" styleClass="form-control" value="#{AdvancedSearchPage.dvFieldName}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">
<span data-toggle="tooltip" data-placement="auto right" class="tooltiplabel text-info" data-original-title="#{bundle['dataverse.identifier.title']}">
#{bundle.identifier}
</span>
</label>
<div class="col-sm-6">
<p:inputText id="dvFieldAlias" styleClass="form-control" value="#{AdvancedSearchPage.dvFieldAlias}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">
<span data-toggle="tooltip" data-placement="auto right" class="tooltiplabel text-info" data-original-title="#{bundle['advanced.search.dataverses.affiliation.tip']}">
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ public void testSearchPermisions() throws InterruptedException {
.body("data.items[0].name", CoreMatchers.is("Darwin's Finches"))
.statusCode(OK.getStatusCode());

Response publishedDataverseSearchableByAlias = UtilIT.search("dvAlias:" + dataverseAlias, nullToken);
publishedDataverseSearchableByAlias.prettyPrint();
publishedDataverseSearchableByAlias.then().assertThat()
.statusCode(OK.getStatusCode())
.body("data.total_count", CoreMatchers.is(1))
.body("data.count_in_response", CoreMatchers.is(1))
.body("data.items[0].name", CoreMatchers.is(dataverseAlias))
.body("data.items[0].type", CoreMatchers.is("dataverse"))
.body("data.items[0].identifier", CoreMatchers.is(dataverseAlias));

Response disableTokenlessSearch = UtilIT.setSetting(SettingsServiceBean.Key.SearchApiRequiresToken, "true");
disableTokenlessSearch.then().assertThat()
.statusCode(OK.getStatusCode());
Expand Down