Giter Site home page Giter Site logo

psolr's Introduction

PSolr

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Total Downloads License

A simple PHP client for Apache Solr that is built on top of Guzzle and inspired by RSolr.

Installation

PSolr can be installed with Composer by adding the library as a dependency to your composer.json file.

{
    "require": {
        "cpliakas/psolr": "*"
    }
}

After running php composer.phar update on the command line, include the autoloader in your PHP scripts so that the SDK classes are made available.

require_once 'vendor/autoload.php';

Please refer to the Composer's documentation for installation and usage instructions.

Usage

Client Instantiation

use PSolr\Client\SolrClient;
use PSolr\Request as Request;

// Connect to a Solr server.
$solr = SolrClient::factory(array(
    'base_url' => 'http://myserver.com:8080', // defaults to "http://localhost:8983"
    'base_path' => '/solr/myIndex',           // defaults to "/solr"
));

Searching Documents

$select = Request\Select::factory()
  ->setQuery('*:*')
  ->setStart(0)
  ->setRows(10)
;

$response = $select->sendRequest($solr);
$response->numFound();

For simple use cases:

$response = $solr->select(array('q' => '*:*'));

Adding Documents

$add = Request\Add::factory();

$document        = new Request\Document();
$document->id    = '123';
$document->title = 'Test document';
$document->tag   = 'Category 1';
$document->tag   = 'Category 2';
$add->addDocument($document);

$response = $add->sendRequest($solr)

Deleting Documents

$response = Request\Delete::factory()
    ->addId('123')
    ->addId('456')
    ->addQuery('platform:solr')
    ->sendRequest($solr)
;

Sending Arbitrary Solr Requests

$response = $solr->get('admin/ping?wt=json')->send()->json();

Refer to Guzzle's documentation for more details on making web requests.

Refer to Apache Solr's documentation for more details on the API.

Integrations

psolr's People

Contributors

cpliakas avatar

Watchers

Benjamin avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.