mirror of https://github.com/apache/lucene.git
Fix for SOLR-3111 - fl param not working when more than one field was specified. Also honors * for "all fields"
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1242150 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
534ecb309b
commit
3f9389b3ea
|
@ -99,9 +99,11 @@ public class LukeRequestHandler extends RequestHandlerBase
|
|||
|
||||
// If no doc is given, show all fields and top terms
|
||||
Set<String> fields = null;
|
||||
if( params.get( CommonParams.FL ) != null ) {
|
||||
fields = new TreeSet<String>(Arrays.asList(params.getParams( CommonParams.FL )));
|
||||
String fl = params.get(CommonParams.FL);
|
||||
if (fl != null) {
|
||||
fields = new TreeSet<String>(Arrays.asList(fl.split( "[,\\s]+" )));
|
||||
}
|
||||
|
||||
if ( "schema".equals( params.get( "show" ))) {
|
||||
numTerms = 0; // Abort any statistics gathering.
|
||||
}
|
||||
|
@ -300,7 +302,7 @@ public class LukeRequestHandler extends RequestHandlerBase
|
|||
Fields theFields = reader.fields();
|
||||
|
||||
for (String fieldName : fieldNames) {
|
||||
if (fields != null && ! fields.contains(fieldName)) {
|
||||
if (fields != null && ! fields.contains(fieldName) && ! fields.contains("*")) {
|
||||
continue; // we're not interested in this term
|
||||
}
|
||||
|
||||
|
@ -522,7 +524,7 @@ public class LukeRequestHandler extends RequestHandlerBase
|
|||
}
|
||||
totalTerms += terms.getUniqueTermCount();
|
||||
|
||||
if (fieldList != null && !fieldList.contains(field)) {
|
||||
if (fieldList != null && ! fieldList.contains(field) && ! fieldList.contains("*")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
package org.apache.solr.handler.admin;
|
||||
|
||||
import org.apache.solr.common.luke.FieldFlag;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
@ -39,32 +41,8 @@ public class LukeRequestHandlerTest extends AbstractSolrTestCase {
|
|||
return "solrconfig.xml";
|
||||
}
|
||||
|
||||
public void testHistogramBucket() {
|
||||
assertHistoBucket(0, 1);
|
||||
assertHistoBucket(1, 2);
|
||||
assertHistoBucket(2, 3);
|
||||
assertHistoBucket(2, 4);
|
||||
assertHistoBucket(3, 5);
|
||||
assertHistoBucket(3, 6);
|
||||
assertHistoBucket(3, 7);
|
||||
assertHistoBucket(3, 8);
|
||||
assertHistoBucket(4, 9);
|
||||
|
||||
final int MAX_VALID = ((Integer.MAX_VALUE/2)+1)/2;
|
||||
|
||||
assertHistoBucket(29, MAX_VALID-1 );
|
||||
assertHistoBucket(29, MAX_VALID );
|
||||
assertHistoBucket(30, MAX_VALID+1 );
|
||||
|
||||
}
|
||||
|
||||
private void assertHistoBucket(int slot, int in) {
|
||||
assertEquals("histobucket: " + in, slot, 32 - Integer.numberOfLeadingZeros(Math.max(0, in - 1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLuke() {
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
assertU(adoc("id","SOLR1000", "name","Apache Solr",
|
||||
"solr_si", "10",
|
||||
"solr_sl", "10",
|
||||
|
@ -94,6 +72,36 @@ public class LukeRequestHandlerTest extends AbstractSolrTestCase {
|
|||
));
|
||||
assertU(commit());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHistogramBucket() {
|
||||
assertHistoBucket(0, 1);
|
||||
assertHistoBucket(1, 2);
|
||||
assertHistoBucket(2, 3);
|
||||
assertHistoBucket(2, 4);
|
||||
assertHistoBucket(3, 5);
|
||||
assertHistoBucket(3, 6);
|
||||
assertHistoBucket(3, 7);
|
||||
assertHistoBucket(3, 8);
|
||||
assertHistoBucket(4, 9);
|
||||
|
||||
final int MAX_VALID = ((Integer.MAX_VALUE/2)+1)/2;
|
||||
|
||||
assertHistoBucket(29, MAX_VALID-1 );
|
||||
assertHistoBucket(29, MAX_VALID );
|
||||
assertHistoBucket(30, MAX_VALID+1 );
|
||||
|
||||
}
|
||||
|
||||
private void assertHistoBucket(int slot, int in) {
|
||||
assertEquals("histobucket: " + in, slot, 32 - Integer.numberOfLeadingZeros(Math.max(0, in - 1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLuke() {
|
||||
|
||||
|
||||
// test that Luke can handle all of the field types
|
||||
assertQ(req("qt","/admin/luke", "id","SOLR1000"));
|
||||
|
||||
|
@ -139,4 +147,36 @@ public class LukeRequestHandlerTest extends AbstractSolrTestCase {
|
|||
return "//lst[@name='fields']/lst[@name='"+field+"']/str";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlParam() {
|
||||
SolrQueryRequest req = req("qt", "/admin/luke", "fl", "solr_t solr_s");
|
||||
try {
|
||||
// First, determine that the two fields ARE there
|
||||
String response = h.query(req);
|
||||
assertNull(h.validateXPath(response,
|
||||
getFieldXPathPrefix("solr_t") + "[@name='index']",
|
||||
getFieldXPathPrefix("solr_s") + "[@name='index']"
|
||||
));
|
||||
|
||||
// Now test that the other fields are NOT there
|
||||
for (String f : Arrays.asList("solr_ti",
|
||||
"solr_td", "solr_pl", "solr_dt", "solr_b")) {
|
||||
|
||||
assertNotNull(h.validateXPath(response,
|
||||
getFieldXPathPrefix(f) + "[@name='index']"));
|
||||
|
||||
}
|
||||
// Insure * works
|
||||
req = req("qt", "/admin/luke", "fl", "*");
|
||||
response = h.query(req);
|
||||
for (String f : Arrays.asList("solr_t", "solr_s", "solr_ti",
|
||||
"solr_td", "solr_pl", "solr_dt", "solr_b")) {
|
||||
|
||||
assertNull(h.validateXPath(response,
|
||||
getFieldXPathPrefix(f) + "[@name='index']"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
fail("Caught unexpected exception " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue