Package org.apache.solr.response

Examples of org.apache.solr.response.SolrQueryResponse



  public void testTemplateName() throws IOException {
    org.apache.solr.response.VelocityResponseWriter vrw = new VelocityResponseWriter();
    SolrQueryRequest req = req("v.template","custom", "v.template.custom","$response.response.response_data");
    SolrQueryResponse rsp = new SolrQueryResponse();
    StringWriter buf = new StringWriter();
    rsp.add("response_data", "testing");
    vrw.write(buf, req, rsp);
    assertEquals("testing", buf.toString());
  }
View Full Code Here


    params.add(ClusteringParams.USE_SEARCH_RESULTS, "true");


    SolrRequestHandler handler = core.getRequestHandler("standard");
    SolrQueryResponse rsp;
    rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
    handler.handleRequest(req, rsp);
    NamedList values = rsp.getValues();
    Object clusters = values.get("clusters");
    //System.out.println("Clusters: " + clusters);
    assertTrue("clusters is null and it shouldn't be", clusters != null);
    req.close();

    params = new ModifiableSolrParams();
    params.add(ClusteringComponent.COMPONENT_NAME, "true");
    params.add(ClusteringParams.ENGINE_NAME, "mock");
    params.add(ClusteringParams.USE_COLLECTION, "true");
    params.add(QueryComponent.COMPONENT_NAME, "false");

    handler = core.getRequestHandler("docClustering");

    rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap());
    req = new LocalSolrQueryRequest(core, params);
    handler.handleRequest(req, rsp);
    values = rsp.getValues();
    clusters = values.get("clusters");
    //System.out.println("Clusters: " + clusters);
    assertTrue("clusters is null and it shouldn't be", clusters != null);
    req.close();
  }
View Full Code Here

    SolrCore core = SolrCore.getSolrCore();
    SolrQueryRequest req = new LocalSolrQueryRequest(core, new HashMap<String,String[]>());
    try {
      // Old style requests do not choose a custom handler
      UpdateRequestProcessorChain processorFactory = core.getUpdateProcessingChain(null);
      SolrQueryResponse rsp = new SolrQueryResponse(); // ignored
      final String charset = ContentStreamBase.getCharsetFromContentType(inputContentType);
      final XMLStreamReader parser = (charset == null) ?
        inputFactory.createXMLStreamReader(input) : inputFactory.createXMLStreamReader(input, charset);
      UpdateRequestProcessor processor = processorFactory.createProcessor(req, rsp);
      XMLLoader loader = (XMLLoader) newLoader(req, processor);
View Full Code Here

                + (inclusive?"":" incu=false")
                + "}";
        qs.add(q);
      }

      SolrQueryResponse last=null;
      for (String q : qs) {
        // System.out.println("QUERY="+q);
        SolrQueryRequest req = req("q",q,"rows","1000");
        SolrQueryResponse qr = h.queryAndResponse(handler, req);
        if (last != null) {
          // we only test if the same docs matched since some queries will include factors like idf, etc.
          sameDocs((DocSet)qr.getValues().get("response"), (DocSet)last.getValues().get("response"));
        }
        req.close();
        last = qr;
      }
    }
View Full Code Here

  // Skip encoding for updating the index
  void createIndex2(int nDocs, String... fields) throws IOException {
    Set<String> fieldSet = new HashSet<String>(Arrays.asList(fields));

    SolrQueryRequest req = lrf.makeRequest();
    SolrQueryResponse rsp = new SolrQueryResponse();
    UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessingChain(null);
    UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp);

    boolean foomany_s = fieldSet.contains("foomany_s");
    boolean foo1_s = fieldSet.contains("foo1_s");
View Full Code Here

    XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler();
    handler.init(null);
    ArrayList<ContentStream> streams = new ArrayList<ContentStream>(2);
    streams.add(new ContentStreamBase.StringStream(doc));
    req.setContentStreams(streams);
    handler.handleRequestBody(req, new SolrQueryResponse());
    req.close();
  }
View Full Code Here

   
    MapSolrParams params = new MapSolrParams( new HashMap<String, String>() );
    params.getMap().put(UpdateParams.UPDATE_CHAIN_DEPRECATED, "nonexistant");

    // Add a single document
    SolrQueryResponse rsp = new SolrQueryResponse();
    SolrQueryRequestBase req = new SolrQueryRequestBase( core, params ) {};
   
    // First check that the old param behaves as it should
    try {
      handler.handleRequestBody(req, rsp);
View Full Code Here

    handler.init( null );
   
    MapSolrParams params = new MapSolrParams( new HashMap<String, String>() );
   
    // Add a single document
    SolrQueryResponse rsp = new SolrQueryResponse();
    SolrQueryRequestBase req = new SolrQueryRequestBase( core, params ) {};
    for( int i=0; i<14; i++ ) {
      req.setContentStreams( toContentStreams(
        adoc("id", "A"+i, "subject", "info" ), null ) );
      handler.handleRequest( req, rsp );
View Full Code Here

    handler.init( null );
   
    MapSolrParams params = new MapSolrParams( new HashMap<String, String>() );
   
    // Add a single document
    SolrQueryResponse rsp = new SolrQueryResponse();
    SolrQueryRequestBase req = new SolrQueryRequestBase( core, params ) {};
    req.setContentStreams( toContentStreams(
      adoc("id", "529", "field_t", "what's inside?", "subject", "info"), null ) );
    trigger.reset();
    handler.handleRequest( req, rsp );
View Full Code Here

    SolrCore core = SearchActivator.getInstance().getSolrCore();
    //this seems to be the only way to obtain the JSON response representation
    SolrQueryRequest solrRequest = null;
    try {
      solrRequest = new LocalSolrQueryRequest(core, query.toNamedList());
      SolrQueryResponse solrResponse = new SolrQueryResponse();
      // Added encoding check as per Bugzilla 406757
      if (httpRequest.getCharacterEncoding() == null) {
        httpRequest.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
        httpResponse.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
      }
      //bash the query in the response to remove user info
      @SuppressWarnings("unchecked")
      NamedList<Object> params = (NamedList<Object>) queryResponse.getHeader().get("params"); //$NON-NLS-1$
      params.remove(CommonParams.Q);
      params.add(CommonParams.Q, httpRequest.getParameter(CommonParams.Q));
      NamedList<Object> values = queryResponse.getResponse();
      String contextPath = httpRequest.getContextPath();
      if (contextPath.length() > 0)
        setSearchResultContext(values, contextPath);
      solrResponse.setAllValues(values);
      QueryResponseWriter writer = core.getQueryResponseWriter("json"); //$NON-NLS-1$
      writer.write(httpResponse.getWriter(), solrRequest, solrResponse);
    } finally {
      if (solrRequest != null) {
        solrRequest.close();
View Full Code Here

TOP

Related Classes of org.apache.solr.response.SolrQueryResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.