add default field (&df) to SolrServlet query if missing

pull/1/head
reger 12 years ago
parent 52dd491c04
commit ab9583d429

@ -122,7 +122,12 @@ public class SolrServlet implements Filter {
// prepare request to solr
hrequest.setAttribute("org.apache.solr.CoreContainer", core);
MultiMapSolrParams mmsp = SolrRequestParsers.parseQueryString(hrequest.getQueryString());
// add default search field if missing
String queryStr = hrequest.getQueryString();
if (!queryStr.contains("&df=")) {
queryStr = queryStr + "&df=*";
}
MultiMapSolrParams mmsp = SolrRequestParsers.parseQueryString(queryStr);
req = connector.request(mmsp);
SolrQueryResponse rsp = connector.query(req);

@ -80,6 +80,7 @@ public class HttpServer {
SolrServlet.initCore(sb.index.fulltext().getDefaultEmbeddedConnector());
solrContext.addFilter(new FilterHolder(SolrServlet.class), "/*", EnumSet.of(DispatcherType.REQUEST));
// configure root context
ServletContextHandler htrootContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
htrootContext.setContextPath("/");
ServletHolder sholder = new ServletHolder(YaCyDefaultServlet.class);

Loading…
Cancel
Save