Search in sources :

Example 1 with Resolver

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();
}
Also used : LocalSolrQueryRequest(org.apache.solr.request.LocalSolrQueryRequest) SolrDocument(org.apache.solr.common.SolrDocument) Resolver(org.apache.solr.response.BinaryResponseWriter.Resolver) Map(java.util.Map) SolrReturnFields(org.apache.solr.search.SolrReturnFields) JavaBinCodec(org.apache.solr.common.util.JavaBinCodec)

Aggregations

Map (java.util.Map)1 SolrDocument (org.apache.solr.common.SolrDocument)1 JavaBinCodec (org.apache.solr.common.util.JavaBinCodec)1 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)1 Resolver (org.apache.solr.response.BinaryResponseWriter.Resolver)1 SolrReturnFields (org.apache.solr.search.SolrReturnFields)1