11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Client APIs<br />

This section discusses the available client APIs for <strong>Solr</strong>. It covers the following topics:<br />

Introduction to Client APIs: A conceptual overview of <strong>Solr</strong> client APIs.<br />

Choosing an Output Format: Information about choosing a response format in <strong>Solr</strong>.<br />

Using JavaScript: Explains why a client API is not needed for JavaScript responses.<br />

Using Python: Information about Python and JSON responses.<br />

Client API Lineup: A list of all <strong>Solr</strong> Client APIs, with links.<br />

Using <strong>Solr</strong>J: Detailed information about <strong>Solr</strong>J, an API for working with Java applications.<br />

Using <strong>Solr</strong> From Ruby: Detailed information about using <strong>Solr</strong> with Ruby applications.<br />

MBean Request Handler: Describes the MBean request handler for programmatic access to <strong>Solr</strong> server statistics<br />

and information.<br />

Introduction to Client APIs<br />

At its heart, <strong>Solr</strong> is a Web application, but because it is built on open protocols, any type of client application can<br />

use <strong>Solr</strong>.<br />

HTTP is the fundamental protocol used between client applications and <strong>Solr</strong>. The client makes a request and<br />

<strong>Solr</strong> does some work and provides a response. Clients use requests to ask <strong>Solr</strong> to do things like perform queries<br />

or index documents.<br />

Client applications can reach <strong>Solr</strong> by creating HTTP requests and parsing the HTTP responses. Client APIs<br />

encapsulate much of the work of sending requests and parsing responses, which makes it much easier to write<br />

client applications.<br />

Clients use <strong>Solr</strong>'s five fundamental operations to work with <strong>Solr</strong>. The operations are query, index, delete, commit,<br />

and optimize.<br />

Queries are executed by creating a URL that contains all the query parameters. <strong>Solr</strong> examines the request URL,<br />

performs the query, and returns the results. The other operations are similar, although in certain cases the HTTP<br />

request is a POST operation and contains information beyond whatever is included in the request URL. An index<br />

operation, for example, may contain a document in the body of the request.<br />

<strong>Solr</strong> also features an Embedded<strong>Solr</strong>Server that offers a Java API without requiring an HTTP connection. For<br />

details, see Using <strong>Solr</strong>J.<br />

Choosing an Output Format<br />

Many programming environments are able to send HTTP requests and retrieve responses. Parsing the<br />

responses is a slightly more thorny problem. Fortunately, <strong>Solr</strong> makes it easy to choose an output format that will<br />

be easy to handle on the client side.<br />

Specify a response format using the wt parameter in a query. The available response formats are documented in<br />

Response Writers.<br />

Most client APIs hide this detail for you, so for many types of client applications, you won't ever have to specify a<br />

wt parameter. In JavaScript, however, the interface to <strong>Solr</strong> is a little closer to the metal, so you will need to add<br />

this parameter yourself.<br />

Client API Lineup<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

640

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!