pankajit / solr-php-client

Automatically exported from code.google.com/p/solr-php-client
Other
0 stars 1 forks source link

Constructor not flexible enough with regards to servlet and path #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'd like to work on making the constructor more flexible so that it doesn't
assume things like that the servlet will be 'select'.

    /**
     * Constructor. All parameters are optional and will take on default values
     * if not specified.
     *
     * @param string $host
     * @param string $port
     * @param string $path
     */
    public function __construct($host = 'localhost', $port = 8180, $path =
'/solr/')
    {
        $this->setHost($host);
        $this->setPort($port);
        $this->setPath($path);

        $this->_initUrls();
    }

    /**
     * Return a valid http URL given this server's host, port and path and a
provided servlet name
     *
     * @param string $servlet
     * @return string
     */
    protected function _constructUrl($servlet, $params = array())
    {
        ...
        return 'http://' . $this->_host . ':' . $this->_port . $this->_path .
$servlet . $queryString;
    }

    /**
     * Construct the Full URLs for the three servlets we reference
     */

// Note that this doesn't take any params...
    protected function _initUrls()
    {
        //Initialize our full servlet URLs now that we have server information
        ...
// This is more or less hardcoded and immutable. 
        $this->_searchUrl = $this->_constructUrl(self::SEARCH_SERVLET);

        $this->_urlsInited = true;
    }

Original issue reported on code.google.com by acquia.t...@googlemail.com on 11 Aug 2009 at 1:47

GoogleCodeExporter commented 9 years ago
Can we outline the use case for this?

My assumption is that you've set up a new requestHandler element in your 
solrconfig.xml and given it a path 
like "/myhandler" rather than a simple name like "myhandler". If you use the 
simple name instead then you 
can access it with the qt=myhandler parameter through the request dispatcher 
(select servlet).

$solr->search("query", 0, 10, array('qt' => 'myhandler'));

I believe this is the preferred best practice since all solr example request 
handlers are setup this way.

Original comment by donovan....@gmail.com on 12 Aug 2009 at 2:29

GoogleCodeExporter commented 9 years ago

Original comment by donovan....@gmail.com on 8 Feb 2010 at 6:27