Package org.apache.solr.request

Examples of org.apache.solr.request.SolrQueryResponse


      UpdateRequestProcessorChain processorFactory = core.getUpdateProcessingChain(null);

      SolrParams params = new MapSolrParams(new HashMap<String, String>());
      SolrQueryRequestBase req = new SolrQueryRequestBase(core, params) {
      };
      SolrQueryResponse rsp = new SolrQueryResponse(); // ignored
      XMLStreamReader parser = inputFactory.createXMLStreamReader(input);
      UpdateRequestProcessor processor = processorFactory.createProcessor(req, rsp);
      XMLLoader loader = (XMLLoader) newLoader(req, processor);
      loader.processUpdate(processor, parser);
      processor.finish();
View Full Code Here


   * @exception Exception any exception in the response.
   * @exception IOException if there is a problem writing the XML
   * @see LocalSolrQueryRequest
   */
  public String query(String handler, SolrQueryRequest req) throws IOException, Exception {
    SolrQueryResponse rsp = queryAndResponse(handler, req);

    StringWriter sw = new StringWriter(32000);
    QueryResponseWriter responseWriter = core.getQueryResponseWriter(req);
    responseWriter.write(sw,req,rsp);

View Full Code Here

    return sw.toString();
  }

  public SolrQueryResponse queryAndResponse(String handler, SolrQueryRequest req) throws Exception {
    SolrQueryResponse rsp = new SolrQueryResponse();
    core.execute(core.getRequestHandler(handler),req,rsp);
    if (rsp.getException() != null) {
      throw rsp.getException();
    }
    return rsp;
  }
View Full Code Here

   * @exception IOException if there is a problem writing the XML
   * @see LocalSolrQueryRequest
   */
  public String query(SolrQueryRequest req) throws IOException, Exception {

    SolrQueryResponse rsp = new SolrQueryResponse();
    core.execute(req,rsp);
    if (rsp.getException() != null) {
      throw rsp.getException();
    }
               
    StringWriter sw = new StringWriter(32000);
    QueryResponseWriter responseWriter = core.getQueryResponseWriter(req);
    responseWriter.write(sw,req,rsp);
View Full Code Here

    MultiMapSolrParams mmparams = new MultiMapSolrParams( params );
    SolrQueryRequestBase req = new SolrQueryRequestBase( core, (SolrParams)mmparams ) {};
   
    // requires 'q' or single content stream
    try {
      mlt.handleRequestBody( req, new SolrQueryResponse() );
    }
    catch( Exception ex ) {} // expected

    // requires 'q' or single content stream
    try {
      ArrayList<ContentStream> streams = new ArrayList<ContentStream>( 2 );
      streams.add( new ContentStreamBase.StringStream( "hello" ) );
      streams.add( new ContentStreamBase.StringStream( "there" ) );
      req.setContentStreams( streams );
      mlt.handleRequestBody( req, new SolrQueryResponse() );
    }
    catch( Exception ex ) {} // expected
   
    assertU(adoc(new String[]{"id","42","name","Tom Cruise","subword","Top Gun","subword","Risky Business","subword","The Color of Money","subword","Minority Report","subword", "Days of Thunder","subword", "Eyes Wide Shut","subword", "Far and Away"}));
    assertU(adoc(new String[]{"id","43","name","Tom Hanks","subword","The Green Mile","subword","Forest Gump","subword","Philadelphia Story","subword","Big","subword","Cast Away"}));
View Full Code Here

    params.add(CommonParams.Q, "bluo");
    params.add(SpellCheckComponent.COMPONENT_NAME, "true");
    params.add(SpellCheckComponent.SPELLCHECK_COUNT, String.valueOf(5));
    params.add(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, String.valueOf(false));
    SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
    SolrQueryResponse rsp;
    rsp = new SolrQueryResponse();
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    NamedList values = rsp.getValues();
    String cmdExec = (String) values.get("command");
    assertTrue("command is null and it shouldn't be", cmdExec != null);
    assertTrue(cmdExec + " is not equal to " + "build",
            cmdExec.equals("build") == true);
    NamedList spellCheck = (NamedList) values.get("spellcheck");
    assertTrue("spellCheck is null and it shouldn't be", spellCheck != null);
    NamedList suggestions = (NamedList) spellCheck.get("suggestions");
    assertTrue("suggestions is null and it shouldn't be", suggestions != null);
    NamedList blue = (NamedList) suggestions.get("bluo");
    assertTrue(blue.get("numFound") + " is not equal to " + "5", blue
            .get("numFound").toString().equals("5") == true);
    Collection<String> theSuggestion = (Collection<String>) blue.get("suggestion");
    assertTrue("theSuggestion is null and it shouldn't be: " + blue,
            theSuggestion != null);
    assertTrue("theSuggestion Size: " + theSuggestion.size() + " is not: " + 5,
            theSuggestion.size() == 5);
    //we know there are at least 5, but now only get 3
    params.remove(SpellCheckComponent.SPELLCHECK_COUNT);
    params.remove(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS);
    params.remove(SpellCheckComponent.SPELLCHECK_BUILD);
    params.add(SpellCheckComponent.SPELLCHECK_COUNT, String.valueOf(3));
    params.add(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, String.valueOf(true));
    params.add(SpellCheckComponent.SPELLCHECK_BUILD, "false");
    rsp = new SolrQueryResponse();
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    values = rsp.getValues();

    spellCheck = (NamedList) values.get("spellcheck");
    assertTrue("spellCheck is null and it shouldn't be", spellCheck != null);
    suggestions = (NamedList) spellCheck.get("suggestions");
    assertTrue("suggestions is null and it shouldn't be", suggestions != null);
View Full Code Here

    params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true");
    params.add(CommonParams.Q, "documemt");
    params.add(SpellCheckComponent.COMPONENT_NAME, "true");

    SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
    SolrQueryResponse rsp = new SolrQueryResponse();
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    NamedList values = rsp.getValues();
    String cmdExec = (String) values.get("command");
    assertTrue("command is null and it shouldn't be", cmdExec != null);
    assertTrue(cmdExec + " is not equal to " + "build",
            cmdExec.equals("build") == true);
    NamedList spellCheck = (NamedList) values.get("spellcheck");
View Full Code Here

    params.add(CommonParams.Q, "documemt");
    params.add(SpellCheckComponent.COMPONENT_NAME, "true");
    params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true");

    SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap());
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    NamedList values = rsp.getValues();
    NamedList spellCheck = (NamedList) values.get("spellcheck");
    assertTrue("spellCheck is null and it shouldn't be", spellCheck != null);
    NamedList suggestions = (NamedList) spellCheck.get("suggestions");
    assertTrue("suggestions is null and it shouldn't be", suggestions != null);
    String collation = (String) suggestions.get("collation");
    assertTrue("collation is null and it shouldn't be", collation != null);
    assertTrue(collation + " is not equal to " + "document", collation.equals("document") == true);
    params.remove(CommonParams.Q);
    params.add(CommonParams.Q, "documemt lowerfilt:broen^4");
    handler = core.getRequestHandler("spellCheckCompRH");
    rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap());
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    values = rsp.getValues();
    spellCheck = (NamedList) values.get("spellcheck");
    assertTrue("spellCheck is null and it shouldn't be", spellCheck != null);
    suggestions = (NamedList) spellCheck.get("suggestions");
    assertTrue("suggestions is null and it shouldn't be", suggestions != null);
    collation = (String) suggestions.get("collation");
    assertTrue("collation is null and it shouldn't be", collation != null);
    assertTrue(collation + " is not equal to " + "document lowerfilt:brown^4", collation.equals("document lowerfilt:brown^4") == true);

    params.remove(CommonParams.Q);
    params.add(CommonParams.Q, "documemtsss broens");
    handler = core.getRequestHandler("spellCheckCompRH");
    rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap());
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    values = rsp.getValues();
    spellCheck = (NamedList) values.get("spellcheck");
    assertTrue("spellCheck is null and it shouldn't be", spellCheck != null);
    suggestions = (NamedList) spellCheck.get("suggestions");
    assertTrue("suggestions is null and it shouldn't be", suggestions != null);
    collation = (String) suggestions.get("collation");
View Full Code Here

    request = req("qt", "spellCheckCompRH", "q", "*:*", "spellcheck.q", "ttle",
        "spellcheck", "true", "spellcheck.dictionary", "default",
        "spellcheck.reload", "true");
    ResponseBuilder rb = new ResponseBuilder();
    rb.req = request;
    rb.rsp = new SolrQueryResponse();
    rb.components = new ArrayList(h.getCore().getSearchComponents().values());
    checker.prepare(rb);

    try {
      checker.process(rb);
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

TOP

Related Classes of org.apache.solr.request.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.