Undid previous changes related to query string cleanup, since eliminating all ParseExceptions is too involved.
This commit is contained in:
parent
bf834bcac6
commit
375f99b99a
3 changed files with 2 additions and 32 deletions
|
@ -59,7 +59,7 @@ import freemarker.template.Configuration;
|
||||||
* through a Lucene search.
|
* through a Lucene search.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AutocompleteController extends BaseSearchController implements Searcher{
|
public class AutocompleteController extends FreemarkerHttpServlet implements Searcher{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Log log = LogFactory.getLog(AutocompleteController.class);
|
private static final Log log = LogFactory.getLog(AutocompleteController.class);
|
||||||
|
@ -282,8 +282,6 @@ public class AutocompleteController extends BaseSearchController implements Sear
|
||||||
// of wildcard and non-wildcard queries. The query will look have only an implicit disjunction
|
// of wildcard and non-wildcard queries. The query will look have only an implicit disjunction
|
||||||
// operator: e.g., +(name:tales name:tales*)
|
// operator: e.g., +(name:tales name:tales*)
|
||||||
try {
|
try {
|
||||||
querystr = cleanQueryString(querystr);
|
|
||||||
|
|
||||||
log.debug("Adding non-wildcard query for " + querystr);
|
log.debug("Adding non-wildcard query for " + querystr);
|
||||||
Query query = parser.parse(querystr);
|
Query query = parser.parse(querystr);
|
||||||
boolQuery.add(query, BooleanClause.Occur.SHOULD);
|
boolQuery.add(query, BooleanClause.Occur.SHOULD);
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.search.controller;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
|
||||||
|
|
||||||
public class BaseSearchController extends FreemarkerHttpServlet {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final Log log = LogFactory.getLog(AutocompleteController.class);
|
|
||||||
|
|
||||||
protected String cleanQueryString(String querystr) {
|
|
||||||
log.debug("Query string is '" + querystr + "'");
|
|
||||||
|
|
||||||
// Prevent org.apache.lucene.queryParser.ParseException:
|
|
||||||
// Cannot parse 'mary *': '*' or '?' not allowed as first character in WildcardQuery
|
|
||||||
// The * is redundant in this case anyway, so just remove it.
|
|
||||||
querystr = querystr.replaceAll("([\\s^])[?*]", "$1");
|
|
||||||
|
|
||||||
log.debug("Cleaned query string is '" + querystr + "'");
|
|
||||||
return querystr;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -83,7 +83,7 @@ import freemarker.template.Configuration;
|
||||||
* Rewritten to use Freemarker: rjy7
|
* Rewritten to use Freemarker: rjy7
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FreemarkerPagedSearchController extends BaseSearchController implements Searcher {
|
public class FreemarkerPagedSearchController extends FreemarkerHttpServlet implements Searcher {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Log log = LogFactory.getLog(FreemarkerPagedSearchController.class.getName());
|
private static final Log log = LogFactory.getLog(FreemarkerPagedSearchController.class.getName());
|
||||||
|
@ -524,8 +524,6 @@ public class FreemarkerPagedSearchController extends BaseSearchController implem
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
QueryParser parser = getQueryParser(analyzer);
|
QueryParser parser = getQueryParser(analyzer);
|
||||||
|
|
||||||
querystr = cleanQueryString(querystr);
|
|
||||||
query = parser.parse(querystr);
|
query = parser.parse(querystr);
|
||||||
|
|
||||||
String alpha = request.getParameter("alpha");
|
String alpha = request.getParameter("alpha");
|
||||||
|
|
Loading…
Add table
Reference in a new issue