mirror of https://github.com/apache/lucene.git
SOLR-70 - better parsing of pingQuery ... it's still not a very clean syntax, but at least it's now possible to have any pingQuery you want and it will acctaully respect multiple query params
git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@486904 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
62989cd49b
commit
b2fcbed95b
|
@ -154,6 +154,7 @@ Bug Fixes
|
|||
8. Escape '>' in XML output (because ]]> is illegal in CharData)
|
||||
9. field boosts weren't being applied and doc boosts were being applied to fields (klaas)
|
||||
10. Multiple-doc update generates well-formed xml (klaas, SOLR-65)
|
||||
11. Better parsing of pingQuery from solrconfig.xml (hossman, SOLR-70)
|
||||
|
||||
Other Changes
|
||||
1. Upgrade to Lucene 2.0 nightly build 2006-06-22, lucene SVN revision 416224,
|
||||
|
|
|
@ -354,8 +354,12 @@
|
|||
<admin>
|
||||
<defaultQuery>solr</defaultQuery>
|
||||
<gettableFiles>solrconfig.xml schema.xml admin-extra.html</gettableFiles>
|
||||
<pingQuery>q=id:0&start=0&rows=0</pingQuery>
|
||||
|
||||
<!-- pingQuery should be "URLish" ...
|
||||
& separated key=val pairs ... but there shouldn't be any
|
||||
URL escaping of the values -->
|
||||
<pingQuery>
|
||||
qt=dismax&q=solr&start=3&fq=id:[* TO *]&fq=cat:[* TO *]
|
||||
</pingQuery>
|
||||
<!-- configure a healthcheck file for servers behind a loadbalancer
|
||||
<healthcheck type="file">server-enabled</healthcheck>
|
||||
-->
|
||||
|
|
|
@ -17,10 +17,15 @@
|
|||
|
||||
package org.apache.solr.core;
|
||||
|
||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.util.NamedList;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
@ -77,4 +82,24 @@ public class SolrConfig {
|
|||
throw new RuntimeException("Error in " + DEFAULT_CONF_FILE, ee);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Request object based on the admin/pingQuery section
|
||||
* of the Solr config file.
|
||||
*/
|
||||
public static SolrQueryRequest getPingQueryRequest(SolrCore core) {
|
||||
|
||||
// TODO: check for nested tags and parse as a named list instead
|
||||
String urlSnippet = config.get("admin/pingQuery", "").trim();
|
||||
|
||||
StringTokenizer qtokens = new StringTokenizer(urlSnippet,"&");
|
||||
String tok;
|
||||
NamedList params = new NamedList();
|
||||
while (qtokens.hasMoreTokens()) {
|
||||
tok = qtokens.nextToken();
|
||||
String[] split = tok.split("=", 2);
|
||||
params.add(split[0], split[1]);
|
||||
}
|
||||
return new LocalSolrQueryRequest(core, params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,5 +61,9 @@ public class LocalSolrQueryRequest extends SolrQueryRequestBase {
|
|||
public LocalSolrQueryRequest(SolrCore core, Map<String,String[]> args) {
|
||||
super(core, new MultiMapSolrParams(args));
|
||||
}
|
||||
public LocalSolrQueryRequest(SolrCore core, SolrParams args) {
|
||||
super(core, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
org.apache.solr.core.SolrException"%>
|
||||
<%@ page import="org.apache.solr.request.LocalSolrQueryRequest"%>
|
||||
<%@ page import="org.apache.solr.request.SolrQueryResponse"%>
|
||||
<%@ page import="java.util.StringTokenizer"%>
|
||||
<%@ page import="org.apache.solr.request.ServletSolrParams"%>
|
||||
<%@ page import="org.apache.solr.request.SolrQueryRequest"%>
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="ping.xsl"?>
|
||||
|
||||
|
@ -30,19 +31,14 @@
|
|||
<%
|
||||
SolrCore core = SolrCore.getSolrCore();
|
||||
|
||||
String queryArgs = (request.getQueryString() == null) ?
|
||||
SolrConfig.config.get("admin/pingQuery","") : request.getQueryString();
|
||||
StringTokenizer qtokens = new StringTokenizer(queryArgs,"&");
|
||||
String tok;
|
||||
String query = null;
|
||||
while (qtokens.hasMoreTokens()) {
|
||||
tok = qtokens.nextToken();
|
||||
String[] split = tok.split("=");
|
||||
if (split[0].startsWith("q")) {
|
||||
query = split[1];
|
||||
}
|
||||
SolrQueryRequest req = null;
|
||||
|
||||
if (null == request.getQueryString()) {
|
||||
req = SolrConfig.getPingQueryRequest(core);
|
||||
} else {
|
||||
req = new LocalSolrQueryRequest(core, new ServletSolrParams(request));
|
||||
}
|
||||
LocalSolrQueryRequest req = new LocalSolrQueryRequest(core, query,null,0,1,LocalSolrQueryRequest.emptyArgs);
|
||||
|
||||
SolrQueryResponse resp = new SolrQueryResponse();
|
||||
try {
|
||||
core.execute(req,resp);
|
||||
|
|
Loading…
Reference in New Issue