SOLR-3795: Fixed LukeRequestHandler response to correctly return field name strings in copyDests and copySources arrays

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1381685 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2012-09-06 17:22:48 +00:00
parent a778718872
commit 2a6f2c7cbb
4 changed files with 51 additions and 3 deletions

View File

@ -131,6 +131,9 @@ Bug Fixes
* SOLR-3679: Core Admin UI gives no feedback if "Add Core" fails (steffkes, hossman) * SOLR-3679: Core Admin UI gives no feedback if "Add Core" fails (steffkes, hossman)
* SOLR-3795: Fixed LukeRequestHandler response to correctly return field name
strings in copyDests and copySources arrays (hossman)
Other Changes Other Changes
---------------------- ----------------------

View File

@ -53,6 +53,7 @@ import org.apache.solr.schema.FieldType;
import org.apache.solr.update.SolrIndexWriter; import org.apache.solr.update.SolrIndexWriter;
import org.apache.solr.schema.IndexSchema; import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField; import org.apache.solr.schema.SchemaField;
import org.apache.solr.schema.CopyField;
import org.apache.solr.search.SolrIndexSearcher; import org.apache.solr.search.SolrIndexSearcher;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -522,8 +523,8 @@ public class LukeRequestHandler extends RequestHandlerBase
if (ft.getAnalyzer().getPositionIncrementGap(f.getName()) != 0) { if (ft.getAnalyzer().getPositionIncrementGap(f.getName()) != 0) {
field.add("positionIncrementGap", ft.getAnalyzer().getPositionIncrementGap(f.getName())); field.add("positionIncrementGap", ft.getAnalyzer().getPositionIncrementGap(f.getName()));
} }
field.add("copyDests", schema.getCopyFieldsList(f.getName())); field.add("copyDests", toListOfStringDests(schema.getCopyFieldsList(f.getName())));
field.add("copySources", schema.getCopySources(f.getName())); field.add("copySources", toListOfStrings(schema.getCopySources(f.getName())));
fields.put( f.getName(), field ); fields.put( f.getName(), field );
@ -617,6 +618,22 @@ public class LukeRequestHandler extends RequestHandlerBase
// Add a histogram // Add a histogram
fieldMap.add("histogram", tiq.histogram.toNamedList()); fieldMap.add("histogram", tiq.histogram.toNamedList());
} }
private static List<String> toListOfStrings(SchemaField[] raw) {
List<String> result = new ArrayList<String>(raw.length);
for (SchemaField f : raw) {
result.add(f.getName());
}
return result;
}
private static List<String> toListOfStringDests(List<CopyField> raw) {
List<String> result = new ArrayList<String>(raw.size());
for (CopyField f : raw) {
result.add(f.getDestination().getName());
}
return result;
}
//////////////////////// SolrInfoMBeans methods ////////////////////// //////////////////////// SolrInfoMBeans methods //////////////////////
@Override @Override

View File

@ -591,6 +591,10 @@
<dynamicField name="random_*" type="random" /> <dynamicField name="random_*" type="random" />
<!-- unused, for testing luke copyFields -->
<dynamicField name="foo_copysource_*" type="ignored" multiValued="true"/>
<dynamicField name="bar_copydest_*" type="ignored" multiValued="true"/>
</fields> </fields>
<defaultSearchField>text</defaultSearchField> <defaultSearchField>text</defaultSearchField>
@ -601,5 +605,7 @@
<copyField source="title" dest="text"/> <copyField source="title" dest="text"/>
<copyField source="subject" dest="text"/> <copyField source="subject" dest="text"/>
<copyField source="foo_copysource_*" dest="bar_copydest_*" />
</schema> </schema>

View File

@ -146,7 +146,12 @@ public class LukeRequestHandlerTest extends AbstractSolrTestCase {
private static String getFieldXPathPrefix(String field) { private static String getFieldXPathPrefix(String field) {
return "//lst[@name='fields']/lst[@name='"+field+"']/str"; return "//lst[@name='fields']/lst[@name='"+field+"']/str";
} }
private static String field(String field) {
return "//lst[@name='fields']/lst[@name='"+field+"']/";
}
private static String dynfield(String field) {
return "//lst[@name='dynamicFields']/lst[@name='"+field+"']/";
}
@Test @Test
public void testFlParam() { public void testFlParam() {
SolrQueryRequest req = req("qt", "/admin/luke", "fl", "solr_t solr_s", "show", "all"); SolrQueryRequest req = req("qt", "/admin/luke", "fl", "solr_t solr_s", "show", "all");
@ -179,4 +184,21 @@ public class LukeRequestHandlerTest extends AbstractSolrTestCase {
fail("Caught unexpected exception " + e.getMessage()); fail("Caught unexpected exception " + e.getMessage());
} }
} }
public void testCopyFieldLists() throws Exception {
SolrQueryRequest req = req("qt", "/admin/luke", "show", "schema");
String xml = h.query(req);
String r = h.validateXPath
(xml,
field("text") + "/arr[@name='copySources']/str[.='title']",
field("text") + "/arr[@name='copySources']/str[.='subject']",
field("title") + "/arr[@name='copyDests']/str[.='text']",
field("title") + "/arr[@name='copyDests']/str[.='title_stemmed']",
// :TODO: SOLR-3798
//dynfield("bar_copydest_*") + "/arr[@name='copySource']/str[.='foo_copysource_*']",
dynfield("foo_copysource_*") + "/arr[@name='copyDests']/str[.='bar_copydest_*']");
assertEquals(xml, null, r);
}
} }