Package org.apache.solr.request

Examples of org.apache.solr.request.SolrRequestHandler


  public String getSolrConfigFile() { return "solrconfig.xml"; }

 
  public void testLazyLoading() {
    SolrCore core = SolrCore.getSolrCore();
    SolrRequestHandler handler = core.getRequestHandler( "lazy" );
    assertFalse( handler instanceof StandardRequestHandler );
   
    // But it should behave just like the 'defaults' request handler above
    assertU(adoc("id", "42",
                 "name", "Zapp Brannigan"));
View Full Code Here


  }
 
  public void testPathNormalization()
  {
    SolrCore core = SolrCore.getSolrCore();
    SolrRequestHandler h1 = core.getRequestHandler("/update/csv" );
    assertNotNull( h1 );

    SolrRequestHandler h2 = core.getRequestHandler("/update/csv/" );
    assertNotNull( h2 );
   
    assertEquals( h1, h2 ); // the same object
   
    assertNull( core.getRequestHandler("/update/csv/asdgadsgas" ) ); // prefix
View Full Code Here

  public SolrRequestHandler register( String handlerName, SolrRequestHandler handler ) {
    String norm = normalize( handlerName );
    if( handler == null ) {
      return handlers.remove( norm );
    }
    SolrRequestHandler old = handlers.put(norm, handler);
    if (handlerName != null && handlerName != "") {
      if (handler instanceof SolrInfoMBean) {
        SolrInfoRegistry.getRegistry().put(handlerName, (SolrInfoMBean)handler);
      }
    }
View Full Code Here

          String className = DOMUtil.getAttr(node,"class","requestHandler config");
          String startup = DOMUtil.getAttr(node,"startup", null );
          NamedList<Object> args = DOMUtil.childNodesToNamedList(node);
 
          // Perhaps lazy load the request handler with a wrapper
          SolrRequestHandler handler = null;
          if( "lazy".equals( startup ) ) {
            log.info("adding lazy requestHandler: " + name + "=" + className);
            handler = new LazyRequestHandlerWrapper( className, args );
          }
          else {
            Class<? extends SolrRequestHandler> clazz = Config.findClass( className, new String[]{} );
            log.info("adding requestHandler: " + name + "=" + className);
            handler = clazz.newInstance();
          }
         
          SolrRequestHandler old = register( name, handler );
          if( old != null ) {
            String msg = "multiple handlers registered on the same path! ignoring: "+old;
            Throwable t = new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );
            SolrConfig.severeErrors.add( t );
            SolrException.logOnce(log,null,t);
          }
          names.put( name, args );
        }
        catch (Exception e) {
          SolrConfig.severeErrors.add( e );
          SolrException.logOnce(log,null,e);
        }
      }
     
      // Call init() on each handler after they have all been registered
      for( Map.Entry<String, NamedList<Object>> reg : names.entrySet() ) {
        try {
          handlers.get( reg.getKey() ).init( reg.getValue() );
        }
        catch( Exception e ) {
          SolrConfig.severeErrors.add( e );
          SolrException.logOnce(log,null,e);
        }
      }
    }
   
    //
    // Get the default handler and add it in the map under null and empty
    // to act as the default.
    //
    SolrRequestHandler handler = get(RequestHandlers.DEFAULT_HANDLER_NAME);
    if (handler == null) {
      handler = new StandardRequestHandler();
      register(RequestHandlers.DEFAULT_HANDLER_NAME, handler);
    }
    register(null, handler);
View Full Code Here

      path= pathAndParams;
      params = new MapSolrParams( new HashMap<String, String>() );
    }
   
    // Extract the handler from the path or params
    SolrRequestHandler handler = core.getRequestHandler( path );
    if( handler == null ) {
      if( "/select".equals( path ) || "/select/".equalsIgnoreCase( path) ) {
        String qt = params.get( SolrParams.QT );
        handler = core.getRequestHandler( qt );
        if( handler == null ) {
View Full Code Here

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    SolrServletRequest solrReq = new SolrServletRequest(core, request);;
    SolrQueryResponse solrRsp = new SolrQueryResponse();
    try {

      SolrRequestHandler handler = core.getRequestHandler(solrReq.getQueryType());
      if (handler==null) {
        log.warning("Unknown Request Handler '" + solrReq.getQueryType() +"' :" + solrReq);
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"Unknown Request Handler '" + solrReq.getQueryType() + "'", true);
      }
      core.execute(handler, solrReq, solrRsp );
View Full Code Here

        if( idx > 0 ) {
          // save the portion after the ':' for a 'handler' path parameter
          path = path.substring( 0, idx );
        }
       
        SolrRequestHandler handler = null;
        if( path.length() > 1 ) { // don't match "" or "/" as valid path
          handler = core.getRequestHandler( path );
        }
        if( handler == null && handleSelect ) {
          if( "/select".equals( path ) || "/select/".equals( path ) ) {
View Full Code Here

TOP

Related Classes of org.apache.solr.request.SolrRequestHandler

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.