Skip to content

Commit

Permalink
added test data for search on :, -, bug #3632
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Apr 7, 2014
1 parent fb64015 commit 6d33315
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
8 changes: 8 additions & 0 deletions scripts/search/tests/data/dv-colon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"alias":"colon",
"name":"Colon",
"affiliation":"Affiliation value",
"contactEmail":"pete@mailinator.com",
"permissionRoot":false,
"description":"A dataverse with a : (a colon) in the description"
}
8 changes: 8 additions & 0 deletions scripts/search/tests/data/dv-dash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"alias":"dash",
"name":"Titanic - 1999",
"affiliation":"Affiliation value",
"contactEmail":"pete@mailinator.com",
"permissionRoot":false,
"description":"A dataverse with a - (a dash) in the description"
}
5 changes: 5 additions & 0 deletions scripts/search/tests/expected/colon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

{
"message":"Exception running search for [:] with filterQueries [] and paginationStart [0]: javax.ejb.EJBException org.apache.solr.client.solrj.impl.HttpSolrServer.RemoteSolrException org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: org.apache.solr.search.SyntaxError: Cannot parse ':': Encountered \" \":\" \": \"\" at line 1, column 0.\nWas expecting one of:\n <NOT> ...\n \"+\" ...\n \"-\" ...\n <BAREOPER> ...\n \"(\" ...\n \"*\" ...\n <QUOTED> ...\n <TERM> ...\n <PREFIXTERM> ...\n <WILDTERM> ...\n <REGEXPTERM> ...\n \"[\" ...\n \"{\" ...\n <LPARAMS> ...\n <NUMBER> ...\n <TERM> ...\n \"*\" ...\n ",
"documentation_url":"http://thedata.org"
}
10 changes: 10 additions & 0 deletions scripts/search/tests/expected/dash
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

{
"q":"*",
"fq_provided":"[]",
"fq_actual":"[({!join from=groups_s to=perms_ss}id:group_public)]",
"total_count":1,
"start":0,
"count_in_response":1,
"items":"[dataverse_10:Dash:10]"
}
9 changes: 9 additions & 0 deletions scripts/search/tests/special-characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# curl -H "Content-type:application/json" -X POST -d @scripts/search/tests/data/dv-colon.json "http://localhost:8080/api/dvs/peteTop?key=pete"
# curl 'http://localhost:8983/solr/collection1/select?rows=100&wt=json&indent=true&q="description:\:"'
diff <(curl -s 'http://localhost:8080/api/search?q=:') scripts/search/tests/expected/colon

# http://stackoverflow.com/questions/18277609/search-in-solr-with-special-characters
# curl -H "Content-type:application/json" -X POST -d @scripts/search/tests/data/dv-dash.json "http://localhost:8080/api/dvs/peteTop?key=pete"
# curl 'http://localhost:8983/solr/collection1/select?rows=100&wt=json&indent=true&q=name:\-'
# diff <(curl -s 'http://localhost:8080/api/search?q=name:"Titanic - 1999"') scripts/search/tests/expected/dash
3 changes: 1 addition & 2 deletions src/main/java/edu/harvard/iq/dataverse/api/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import edu.harvard.iq.dataverse.DataverseUserServiceBean;
import edu.harvard.iq.dataverse.FacetCategory;
import edu.harvard.iq.dataverse.FacetLabel;
import edu.harvard.iq.dataverse.IndexServiceBean;
import edu.harvard.iq.dataverse.SolrSearchResult;
import edu.harvard.iq.dataverse.SearchServiceBean;
import edu.harvard.iq.dataverse.SolrQueryResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
Expand Down Expand Up @@ -66,6 +64,7 @@ public String search(@QueryParam("key") String apiKey, @QueryParam("q") String q
cause = cause.getCause();
sb.append(cause.getClass().getCanonicalName() + " ");
sb.append(cause + " ");
// if you search for a colon you see RemoteSolrException: org.apache.solr.search.SyntaxError: Cannot parse ':'
}
String message = "Exception running search for [" + query + "] with filterQueries " + filterQueries + " and paginationStart [" + paginationStart + "]: " + sb.toString();
logger.info(message);
Expand Down

0 comments on commit 6d33315

Please sign in to comment.