solr Client

  • Home
  • Solr Client
  • APIs
    • JAVA
    • PHP
    • Shell
  • Links
PHP Clients
  • Apache Solr PHP Extension
  • Generic PHP Client
  • SolrQuery - PHP query client for Solr
  • SolrUpdate - PHP update client for Solr
  • solr-php-client
API Clients
  • Apache Solr PHP Extension
  • Haystack for Django
  • Flash Client: solr-sunspot
  • Minig's Solr Client
  • solrpy
  • Django Solr
  • Post Multiple Files to a Solr Server
  • Solr Delete Post for Shells
  • Generic PHP Client
  • SolrJ
Other Clients
  • Solr for WordPress
  • Drupal 5 Solr
  • solr Client
Home

Generic PHP Client

Tue, 03/23/2010 - 13:56 |  admin


define("DEFAULT_URL","http://solr.myhost.com:8080/solr/select");
define("DEFAULT_ROWS","15");
define("DEFAULT_FIELDLIST","score,id,title,url,type,created_date,modified_date,icon,logo");
define("DEFAULT_SORT","score desc");

// instantiate a solr class
$s = new solr();
$s->query("google AND microsoft");

/* solr client class definition */
class solr{

public $hostname;
public $queryString;
public $serializedResult;
public $rows;
public $fieldList;

function __construct ($hostname=DEFAULT_URL){
$this->hostname=$hostname;
$this->rows=DEFAULT_ROWS;
$this->fieldList=DEFAULT_FIELDLIST;
}

function query($keywords){

$this->queryString=$this->hostname .
"?q=" . urlencode($keywords) .
"&wt=phps" . "&fl=" . urlencode($this->fieldList) .
"&rows=" . urlencode( $this->rows) .
"&sort=" . urlencode(DEFAULT_SORT) ;

$this->serializedResult = file_get_contents($this->queryString);
$this->result = unserialize($this->serializedResult);
}

function setLimit($rows){
$this->rows = (int)$rows;
}

function setFieldList($fieldList){
$this->fieldList = $fieldList;
}

}

Add new comment |  Tags: API, PHP

Search

Contact Us | Terms of Use | Trademarks | Privacy Statement
Copyright © 2010 solr Client. All Rights Reserved.

Powered by Drupal and Drupal Theme created with Artisteer.