use of org.apache.solr.response.BinaryResponseWriter.Resolver in project lucene-solr by apache.
the class TestBinaryResponseWriter method testResolverSolrDocumentPartialFields.
public void testResolverSolrDocumentPartialFields() throws Exception {
LocalSolrQueryRequest req = lrf.makeRequest("q", "*:*", "fl", "id,xxx,ddd_s");
SolrDocument in = new SolrDocument();
in.addField("id", 345);
in.addField("aaa_s", "aaa");
in.addField("bbb_s", "bbb");
in.addField("ccc_s", "ccc");
in.addField("ddd_s", "ddd");
in.addField("eee_s", "eee");
Resolver r = new Resolver(req, new SolrReturnFields(req));
Object o = r.resolve(in, new JavaBinCodec());
assertNotNull("obj is null", o);
assertTrue("obj is not doc", o instanceof SolrDocument);
SolrDocument out = new SolrDocument();
for (Map.Entry<String, Object> e : in) {
if (r.isWritable(e.getKey()))
out.put(e.getKey(), e.getValue());
}
assertTrue("id not found", out.getFieldNames().contains("id"));
assertTrue("ddd_s not found", out.getFieldNames().contains("ddd_s"));
assertEquals("Wrong number of fields found", 2, out.getFieldNames().size());
req.close();
}
Aggregations