SOLR-3370: fixed CSVResponseWriter to respect globs in the 'fl' param

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1333760 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2012-05-04 05:29:59 +00:00
parent a8beeff4e9
commit d90bbdb836
3 changed files with 25 additions and 1 deletions

View File

@ -405,6 +405,9 @@ Bug Fixes
CoreAdminHandler could return consistent information regardless of wether
there is a a default core name or not. (steffkes, hossman)
* SOLR-3370: fixed CSVResponseWriter to respect globs in the 'fl' param
(Keith Fligg via hossman)
Other Changes
----------------------

View File

@ -258,6 +258,10 @@ class CSVWriter extends TextResponseWriter {
CSVSharedBufPrinter csvPrinterMV = new CSVSharedBufPrinter(mvWriter, mvStrategy);
for (String field : fields) {
if (!returnFields.wantsField(field)) {
continue;
}
if (field.equals("score")) {
CSVField csvField = new CSVField();
csvField.name = "score";

View File

@ -163,6 +163,23 @@ public class TestCSVResponseWriter extends SolrTestCaseJ4 {
w.write(buf, req, rsp);
String s = buf.toString();
assertTrue(s.indexOf("score") >=0 && s.indexOf("2.718") > 0 && s.indexOf("89.83") > 0 );
// Test field globs
rsp.setReturnFields( new ReturnFields("id,foo*", req) );
buf = new StringWriter();
w.write(buf, req, rsp);
assertEquals("id,foo_i,foo_s,foo_l,foo_b,foo_f,foo_d,foo_dt\n" +
"1,-1,hi,12345678987654321L,false,1.414,-1.0E300,2000-01-02T03:04:05Z\n" +
"2,,,,,,,\n",
buf.toString());
rsp.setReturnFields( new ReturnFields("id,*_d*", req) );
buf = new StringWriter();
w.write(buf, req, rsp);
assertEquals("id,foo_d,foo_dt\n" +
"1,-1.0E300,2000-01-02T03:04:05Z\n" +
"2,,\n",
buf.toString());
req.close();
}
@ -176,4 +193,4 @@ public class TestCSVResponseWriter extends SolrTestCaseJ4 {
return Arrays.toString(output);
}
}
}