{"id":561,"date":"2020-02-14T08:13:48","date_gmt":"2020-02-14T08:13:48","guid":{"rendered":"https:\/\/www.aeologic.com\/blog\/?p=561"},"modified":"2020-03-18T08:11:29","modified_gmt":"2020-03-18T08:11:29","slug":"ultimate-solr-guide-10-solr-client-apis","status":"publish","type":"post","link":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/","title":{"rendered":"Solr Client API&#8217;s &#8211; Ultimate Solr Guide"},"content":{"rendered":"<p>Hello Everyone! Today we will discuss another important aspect in solr which is widely used in enterprise-grade applications harnessing the power of solr. In most scenarios, we need to interact with data types of different types and from different sources. Solr provides with multiple client Api&#8217;s to deal with this type of scenario and do much more.<\/p>\n<h1 class=\"post-title-main\">Introduction to Client APIs<\/h1>\n<div class=\"paragraph\">\n<p>At its heart, Solr is a Web application, but because it is built on open protocols, any type of client application can use Solr.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>HTTP is the fundamental protocol used between client applications and Solr. The client makes a request and Solr does some work and provides a response. Clients use requests to ask Solr to do things like performing queries or index documents.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Client applications can reach Solr by creating HTTP requests and parsing the HTTP responses. Client APIs encapsulate much of the work of sending requests and parsing responses, which makes it much easier to write client applications.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Clients use Solr\u2019s five fundamental operations to work with Solr. The operations are query, index, delete, commit, and optimize.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Queries are executed by creating a URL that contains all the query parameters. Solr examines the request URL, performs the query, and returns the results. The other operations are similar, although in certain cases the HTTP request is a POST operation and contains information beyond whatever is included in the request URL. An index operation, for example, may contain a document in the body of the request.<\/p>\n<h1 class=\"post-title-main\">Choosing an Output Format<\/h1>\n<div class=\"main-content\">\n<div class=\"paragraph\">\n<p>Many programming environments are able to send HTTP requests and retrieve responses. Parsing the responses is a slightly more thorny problem. Fortunately, Solr makes it easy to choose an output format that will be easy to handle on the client side.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Specify a response format using the\u00a0<code>wt<\/code> parameter in a query.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Most client APIs hide this detail for you, so for many types of client applications, you won\u2019t ever have to specify a\u00a0<code>wt<\/code>\u00a0parameter. In JavaScript, however, the interface to Solr is a little closer to the metal, so you will need to add this parameter yourself.<\/p>\n<\/div>\n<h1 class=\"post-title-main\">Client API Lineup<\/h1>\n<p>As of now, solr has follwoing client API&#8217;s in provision:<\/p>\n<table class=\"tableblock frame-all grid-all spread\">\n<colgroup>\n<col \/>\n<col \/>\n<col \/><\/colgroup>\n<thead>\n<tr>\n<th class=\"tableblock halign-left valign-top\">Name<\/th>\n<th class=\"tableblock halign-left valign-top\">Environment<\/th>\n<th class=\"tableblock halign-left valign-top\">URL<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">SolRuby<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Ruby<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"https:\/\/github.com\/rsolr\/rsolr\">https:\/\/github.com\/rsolr\/rsolr<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">DelSolr<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Ruby<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"https:\/\/github.com\/avvo\/delsolr\">https:\/\/github.com\/avvo\/delsolr<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">acts_as_solr<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Rails<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/acts-as-solr.rubyforge.org\/\">http:\/\/acts-as-solr.rubyforge.org\/<\/a>,\u00a0<a class=\"bare\" href=\"http:\/\/rubyforge.org\/projects\/background-solr\/\">http:\/\/rubyforge.org\/projects\/background-solr\/<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Flare<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Rails<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/wiki.apache.org\/solr\/Flare\">http:\/\/wiki.apache.org\/solr\/Flare<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">SolPHP<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">PHP<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/wiki.apache.org\/solr\/SolPHP\">http:\/\/wiki.apache.org\/solr\/SolPHP<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">SolrJ<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Java<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/wiki.apache.org\/solr\/SolJava\">http:\/\/wiki.apache.org\/solr\/SolJava<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Python API<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Python<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/wiki.apache.org\/solr\/SolPython\">http:\/\/wiki.apache.org\/solr\/SolPython<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">PySolr<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Python<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/code.google.com\/p\/pysolr\/\">http:\/\/code.google.com\/p\/pysolr\/<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">SolPerl<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Perl<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/wiki.apache.org\/solr\/SolPerl\">http:\/\/wiki.apache.org\/solr\/SolPerl<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Solr.pm<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Perl<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/search.cpan.org\/~garafola\/Solr-0.03\/lib\/Solr.pm\">http:\/\/search.cpan.org\/~garafola\/Solr-0.03\/lib\/Solr.pm<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">SolrForrest<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">Forrest\/Cocoon<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/wiki.apache.org\/solr\/SolrForrest\">http:\/\/wiki.apache.org\/solr\/SolrForrest<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">SolrSharp<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">C#<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/www.codeplex.com\/solrsharp\">http:\/\/www.codeplex.com\/solrsharp<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">SolColdfusion<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">ColdFusion<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/solcoldfusion.riaforge.org\/\">http:\/\/solcoldfusion.riaforge.org\/<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">SolrNet<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">.NET<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"https:\/\/github.com\/mausch\/SolrNet\">https:\/\/github.com\/mausch\/SolrNet<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">AJAX Solr<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\">AJAX<\/p>\n<\/td>\n<td class=\"tableblock halign-left valign-top\">\n<p class=\"tableblock\"><a class=\"bare\" href=\"http:\/\/github.com\/evolvingweb\/ajax-solr\/wiki\">http:\/\/github.com\/evolvingweb\/ajax-solr\/wiki<\/a><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1 class=\"post-title-main\">Using JavaScript<\/h1>\n<div class=\"paragraph\">\n<p>Using Solr from JavaScript clients is so straightforward that it deserves a special mention. In fact, it is so straightforward that there is no client API. You don\u2019t need to install any packages or configure anything.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>HTTP requests can be sent to Solr using the standard\u00a0<code>XMLHttpRequest<\/code>\u00a0mechanism.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>By default, Solr sends Javascript Object Notation(JSON) responses, which are easily interpreted in JavaScript. You don\u2019t need to add anything to the request URL to have responses sent as JSON.<\/p>\n<\/div>\n<h1 class=\"post-title-main\">Using SolrJ<\/h1>\n<h2 id=\"building-and-running-solrj-applications\" class=\"clickable-header top-level-header\">Building and Running SolrJ Applications<\/h2>\n<div class=\"paragraph\">\n<p>The SolrJ API ships with Solr, so you do not have to download or install anything else. But you will need to configure your build to include SolrJ and its dependencies.<\/p>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"common-build-systems\" class=\"clickable-header\">Common Build Systems<\/h3>\n<div class=\"paragraph\">\n<p>Most mainstream build systems greatly simplify dependency management, making it easy to add SolrJ to your project.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>For projects built with Ant (using\u00a0<a href=\"http:\/\/ant.apache.org\/ivy\/\">Ivy<\/a>), place the following in your\u00a0<code>ivy.xml<\/code>:<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-562\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-23.png\" alt=\"\" width=\"698\" height=\"205\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-23.png 698w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-23-300x88.png 300w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-23-260x76.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-23-272x80.png 272w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-23-250x73.png 250w\" sizes=\"(max-width: 698px) 100vw, 698px\" \/><\/p>\n<p>For projects built with Maven, place the following in your\u00a0<code>pom.xml<\/code><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-563\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-24.png\" alt=\"\" width=\"462\" height=\"277\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-24.png 462w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-24-300x180.png 300w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-24-260x156.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-24-133x80.png 133w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-24-250x150.png 250w\" sizes=\"(max-width: 462px) 100vw, 462px\" \/><\/p>\n<p>For projects built with Gradle, place the following in your\u00a0<code>build.gradle<\/code>:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-564\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-25.png\" alt=\"\" width=\"740\" height=\"205\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-25.png 740w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-25-300x83.png 300w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-25-720x199.png 720w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-25-260x72.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-25-289x80.png 289w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-25-250x69.png 250w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/p>\n<\/div>\n<h3 id=\"adding-solrj-to-the-classpath-manually\" class=\"clickable-header\">Adding SolrJ to the Classpath Manually<\/h3>\n<div class=\"paragraph\">\n<p>If you are not using one of the above build system, it\u2019s still easy to add SolrJ to your build.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>At build time, all that is required is the SolrJ jar itself:\u00a0<code>solr-solrj-7.4.0.jar<\/code>. To compile code manually that uses SolrJ, use a\u00a0<code>javac<\/code>\u00a0command similar to:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-566\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-26.png\" alt=\"\" width=\"589\" height=\"205\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-26.png 589w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-26-300x104.png 300w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-26-260x90.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-26-230x80.png 230w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-26-250x87.png 250w\" sizes=\"(max-width: 589px) 100vw, 589px\" \/><\/p>\n<p>At runtime, you need a few of SolrJ\u2019s dependencies, in addition to SolrJ itself. For convenience, these dependencies are made available in the\u00a0<code>dist\/solrj-lib<\/code>\u00a0directory. Run your project with a classpath like:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-567\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-27.png\" alt=\"\" width=\"816\" height=\"205\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-27.png 816w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-27-300x75.png 300w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-27-768x193.png 768w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-27-720x181.png 720w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-27-260x65.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-27-318x80.png 318w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-27-250x63.png 250w\" sizes=\"(max-width: 816px) 100vw, 816px\" \/><\/p>\n<h2 id=\"querying-in-solrj\" class=\"clickable-header top-level-header\">Querying in SolrJ<\/h2>\n<div class=\"paragraph\">\n<p><code>SolrClient<\/code>\u00a0has a number of\u00a0<code>query()<\/code>\u00a0methods for fetching results from Solr. Each of these methods takes in a\u00a0<code>SolrParams<\/code>,an object encapsulating arbitrary query-parameters. And each method outputs a\u00a0<code>QueryResponse<\/code>, a wrapper which can be used to access the result documents and other related metadata.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>The following snippet uses a SolrClient to query Solr\u2019s &#8220;techproducts&#8221; example collection, and iterate over the results.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-568\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-28.png\" alt=\"\" width=\"765\" height=\"511\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-28.png 765w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-28-300x200.png 300w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-28-674x450.png 674w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-28-260x174.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-28-120x80.png 120w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-28-250x167.png 250w\" sizes=\"(max-width: 765px) 100vw, 765px\" \/><\/p>\n<p><code>SolrParams<\/code>\u00a0has a\u00a0<code>SolrQuery<\/code>\u00a0subclass, which provides some convenience methods that greatly simplifies query creation. The following snippet shows how the query from the previous example can be built using some of the convenience methods in\u00a0<code>SolrQuery<\/code>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-569\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-29.png\" alt=\"\" width=\"529\" height=\"277\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-29.png 529w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-29-300x157.png 300w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-29-260x136.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-29-153x80.png 153w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-29-250x131.png 250w\" sizes=\"(max-width: 529px) 100vw, 529px\" \/><\/p>\n<h2 id=\"indexing-in-solrj\" class=\"clickable-header top-level-header\">Indexing in SolrJ<\/h2>\n<div class=\"paragraph\">\n<p>Indexing is also simple using SolrJ. Users build the documents they want to index as instances of\u00a0<code>SolrInputDocument<\/code>, and provide them as arguments to one of the\u00a0<code>add()<\/code>\u00a0methods on\u00a0<code>SolrClient<\/code>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>The following example shows how to use SolrJ to add a document to Solr\u2019s &#8220;techproducts&#8221; example collection:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-570\" src=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-30.png\" alt=\"\" width=\"740\" height=\"331\" srcset=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-30.png 740w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-30-300x134.png 300w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-30-720x322.png 720w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-30-260x116.png 260w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-30-179x80.png 179w, https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/carbon-30-250x112.png 250w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/p>\n<p>So , this is it about solr client API&#8217;s. We will be back with another post very soon.10 Solr Client API&#8217;s<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello Everyone! Today we will discuss another important aspect in solr which is widely used in enterprise-grade applications harnessing the power of solr. In most scenarios, we need to interact with data types of different types and from different sources. Solr provides with multiple client Api&#8217;s to deal with this type of scenario and do much more. Introduction to Client APIs At its heart, Solr is a Web application, but because it is built on open protocols, any type of client application can use Solr. HTTP is the fundamental protocol used between client applications and Solr. The client makes a request and Solr does some work and provides a response. Clients use requests to ask Solr to do things like performing queries or index documents. Client applications can reach Solr by creating HTTP requests and parsing the HTTP responses. Client APIs encapsulate much of the work of sending requests and parsing responses, which makes it much easier to write client applications. Clients use Solr\u2019s five fundamental operations to work with Solr. The operations are query, index, delete, commit, and optimize. Queries are executed by creating a URL that contains all the query parameters. Solr examines the request URL, performs the query, and returns the results. The other operations are similar, although in certain cases the HTTP request is a POST operation and contains information beyond whatever is included in the request URL. An index operation, for example, may contain a document in the body of the request. Choosing an Output Format Many programming environments are able to send HTTP requests and retrieve responses. Parsing the responses is a slightly more thorny problem. Fortunately, Solr makes it easy to choose an output format that will be easy to handle on the client side. Specify a response format using the\u00a0wt parameter in a query. Most client APIs hide this detail for you, so for many types of client applications, you won\u2019t ever have to specify a\u00a0wt\u00a0parameter. In JavaScript, however, the interface to Solr is a little closer to the metal, so you will need to add this parameter yourself. Client API Lineup As of now, solr has follwoing client API&#8217;s in provision: Name Environment URL SolRuby Ruby https:\/\/github.com\/rsolr\/rsolr DelSolr Ruby https:\/\/github.com\/avvo\/delsolr acts_as_solr Rails http:\/\/acts-as-solr.rubyforge.org\/,\u00a0http:\/\/rubyforge.org\/projects\/background-solr\/ Flare Rails http:\/\/wiki.apache.org\/solr\/Flare SolPHP PHP http:\/\/wiki.apache.org\/solr\/SolPHP SolrJ Java http:\/\/wiki.apache.org\/solr\/SolJava Python API Python http:\/\/wiki.apache.org\/solr\/SolPython PySolr Python http:\/\/code.google.com\/p\/pysolr\/ SolPerl Perl http:\/\/wiki.apache.org\/solr\/SolPerl Solr.pm Perl http:\/\/search.cpan.org\/~garafola\/Solr-0.03\/lib\/Solr.pm SolrForrest Forrest\/Cocoon http:\/\/wiki.apache.org\/solr\/SolrForrest SolrSharp C# http:\/\/www.codeplex.com\/solrsharp SolColdfusion ColdFusion http:\/\/solcoldfusion.riaforge.org\/ SolrNet .NET https:\/\/github.com\/mausch\/SolrNet AJAX Solr AJAX http:\/\/github.com\/evolvingweb\/ajax-solr\/wiki Using JavaScript Using Solr from JavaScript clients is so straightforward that it deserves a special mention. In fact, it is so straightforward that there is no client API. You don\u2019t need to install any packages or configure anything. HTTP requests can be sent to Solr using the standard\u00a0XMLHttpRequest\u00a0mechanism. By default, Solr sends Javascript Object Notation(JSON) responses, which are easily interpreted in JavaScript. You don\u2019t need to add anything to the request URL to have responses sent as JSON. Using SolrJ Building and Running SolrJ Applications The SolrJ API ships with Solr, so you do not have to download or install anything else. But you will need to configure your build to include SolrJ and its dependencies. Common Build Systems Most mainstream build systems greatly simplify dependency management, making it easy to add SolrJ to your project. For projects built with Ant (using\u00a0Ivy), place the following in your\u00a0ivy.xml: For projects built with Maven, place the following in your\u00a0pom.xml For projects built with Gradle, place the following in your\u00a0build.gradle: Adding SolrJ to the Classpath Manually If you are not using one of the above build system, it\u2019s still easy to add SolrJ to your build. At build time, all that is required is the SolrJ jar itself:\u00a0solr-solrj-7.4.0.jar. To compile code manually that uses SolrJ, use a\u00a0javac\u00a0command similar to: At runtime, you need a few of SolrJ\u2019s dependencies, in addition to SolrJ itself. For convenience, these dependencies are made available in the\u00a0dist\/solrj-lib\u00a0directory. Run your project with a classpath like: Querying in SolrJ SolrClient\u00a0has a number of\u00a0query()\u00a0methods for fetching results from Solr. Each of these methods takes in a\u00a0SolrParams,an object encapsulating arbitrary query-parameters. And each method outputs a\u00a0QueryResponse, a wrapper which can be used to access the result documents and other related metadata. The following snippet uses a SolrClient to query Solr\u2019s &#8220;techproducts&#8221; example collection, and iterate over the results. SolrParams\u00a0has a\u00a0SolrQuery\u00a0subclass, which provides some convenience methods that greatly simplifies query creation. The following snippet shows how the query from the previous example can be built using some of the convenience methods in\u00a0SolrQuery: Indexing in SolrJ Indexing is also simple using SolrJ. Users build the documents they want to index as instances of\u00a0SolrInputDocument, and provide them as arguments to one of the\u00a0add()\u00a0methods on\u00a0SolrClient. The following example shows how to use SolrJ to add a document to Solr\u2019s &#8220;techproducts&#8221; example collection: So , this is it about solr client API&#8217;s. We will be back with another post very soon.10 Solr Client API&#8217;s<\/p>\n","protected":false},"author":3,"featured_media":574,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[84,7,86,85],"class_list":["post-561","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-solr","tag-client-api","tag-solr","tag-solr-client-apis","tag-solrj"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Solr Client API&#039;s - Ultimate Solr Guide - Aeologic Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Solr Client API&#039;s - Ultimate Solr Guide - Aeologic Blog\" \/>\n<meta property=\"og:description\" content=\"Hello Everyone! Today we will discuss another important aspect in solr which is widely used in enterprise-grade applications harnessing the power of solr. In most scenarios, we need to interact with data types of different types and from different sources. Solr provides with multiple client Api&#8217;s to deal with this type of scenario and do much more. Introduction to Client APIs At its heart, Solr is a Web application, but because it is built on open protocols, any type of client application can use Solr. HTTP is the fundamental protocol used between client applications and Solr. The client makes a request and Solr does some work and provides a response. Clients use requests to ask Solr to do things like performing queries or index documents. Client applications can reach Solr by creating HTTP requests and parsing the HTTP responses. Client APIs encapsulate much of the work of sending requests and parsing responses, which makes it much easier to write client applications. Clients use Solr\u2019s five fundamental operations to work with Solr. The operations are query, index, delete, commit, and optimize. Queries are executed by creating a URL that contains all the query parameters. Solr examines the request URL, performs the query, and returns the results. The other operations are similar, although in certain cases the HTTP request is a POST operation and contains information beyond whatever is included in the request URL. An index operation, for example, may contain a document in the body of the request. Choosing an Output Format Many programming environments are able to send HTTP requests and retrieve responses. Parsing the responses is a slightly more thorny problem. Fortunately, Solr makes it easy to choose an output format that will be easy to handle on the client side. Specify a response format using the\u00a0wt parameter in a query. Most client APIs hide this detail for you, so for many types of client applications, you won\u2019t ever have to specify a\u00a0wt\u00a0parameter. In JavaScript, however, the interface to Solr is a little closer to the metal, so you will need to add this parameter yourself. Client API Lineup As of now, solr has follwoing client API&#8217;s in provision: Name Environment URL SolRuby Ruby https:\/\/github.com\/rsolr\/rsolr DelSolr Ruby https:\/\/github.com\/avvo\/delsolr acts_as_solr Rails http:\/\/acts-as-solr.rubyforge.org\/,\u00a0http:\/\/rubyforge.org\/projects\/background-solr\/ Flare Rails http:\/\/wiki.apache.org\/solr\/Flare SolPHP PHP http:\/\/wiki.apache.org\/solr\/SolPHP SolrJ Java http:\/\/wiki.apache.org\/solr\/SolJava Python API Python http:\/\/wiki.apache.org\/solr\/SolPython PySolr Python http:\/\/code.google.com\/p\/pysolr\/ SolPerl Perl http:\/\/wiki.apache.org\/solr\/SolPerl Solr.pm Perl http:\/\/search.cpan.org\/~garafola\/Solr-0.03\/lib\/Solr.pm SolrForrest Forrest\/Cocoon http:\/\/wiki.apache.org\/solr\/SolrForrest SolrSharp C# http:\/\/www.codeplex.com\/solrsharp SolColdfusion ColdFusion http:\/\/solcoldfusion.riaforge.org\/ SolrNet .NET https:\/\/github.com\/mausch\/SolrNet AJAX Solr AJAX http:\/\/github.com\/evolvingweb\/ajax-solr\/wiki Using JavaScript Using Solr from JavaScript clients is so straightforward that it deserves a special mention. In fact, it is so straightforward that there is no client API. You don\u2019t need to install any packages or configure anything. HTTP requests can be sent to Solr using the standard\u00a0XMLHttpRequest\u00a0mechanism. By default, Solr sends Javascript Object Notation(JSON) responses, which are easily interpreted in JavaScript. You don\u2019t need to add anything to the request URL to have responses sent as JSON. Using SolrJ Building and Running SolrJ Applications The SolrJ API ships with Solr, so you do not have to download or install anything else. But you will need to configure your build to include SolrJ and its dependencies. Common Build Systems Most mainstream build systems greatly simplify dependency management, making it easy to add SolrJ to your project. For projects built with Ant (using\u00a0Ivy), place the following in your\u00a0ivy.xml: For projects built with Maven, place the following in your\u00a0pom.xml For projects built with Gradle, place the following in your\u00a0build.gradle: Adding SolrJ to the Classpath Manually If you are not using one of the above build system, it\u2019s still easy to add SolrJ to your build. At build time, all that is required is the SolrJ jar itself:\u00a0solr-solrj-7.4.0.jar. To compile code manually that uses SolrJ, use a\u00a0javac\u00a0command similar to: At runtime, you need a few of SolrJ\u2019s dependencies, in addition to SolrJ itself. For convenience, these dependencies are made available in the\u00a0dist\/solrj-lib\u00a0directory. Run your project with a classpath like: Querying in SolrJ SolrClient\u00a0has a number of\u00a0query()\u00a0methods for fetching results from Solr. Each of these methods takes in a\u00a0SolrParams,an object encapsulating arbitrary query-parameters. And each method outputs a\u00a0QueryResponse, a wrapper which can be used to access the result documents and other related metadata. The following snippet uses a SolrClient to query Solr\u2019s &#8220;techproducts&#8221; example collection, and iterate over the results. SolrParams\u00a0has a\u00a0SolrQuery\u00a0subclass, which provides some convenience methods that greatly simplifies query creation. The following snippet shows how the query from the previous example can be built using some of the convenience methods in\u00a0SolrQuery: Indexing in SolrJ Indexing is also simple using SolrJ. Users build the documents they want to index as instances of\u00a0SolrInputDocument, and provide them as arguments to one of the\u00a0add()\u00a0methods on\u00a0SolrClient. The following example shows how to use SolrJ to add a document to Solr\u2019s &#8220;techproducts&#8221; example collection: So , this is it about solr client API&#8217;s. We will be back with another post very soon.10 Solr Client API&#8217;s\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/\" \/>\n<meta property=\"og:site_name\" content=\"Aeologic Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AeoLogicTech\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-14T08:13:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-18T08:11:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/Solr-Client-APIs.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1080\" \/>\n\t<meta property=\"og:image:height\" content=\"622\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Manoj Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@aeologictech\" \/>\n<meta name=\"twitter:site\" content=\"@aeologictech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Manoj Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/\"},\"author\":{\"name\":\"Manoj Kumar\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/13549984ba8e5f441cc733ed20d7daa4\"},\"headline\":\"Solr Client API&#8217;s &#8211; Ultimate Solr Guide\",\"datePublished\":\"2020-02-14T08:13:48+00:00\",\"dateModified\":\"2020-03-18T08:11:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/\"},\"wordCount\":925,\"publisher\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/Solr-Client-APIs.png\",\"keywords\":[\"client api\",\"solr\",\"solr client apis\",\"solrj\"],\"articleSection\":[\"Solr\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/\",\"url\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/\",\"name\":\"Solr Client API's - Ultimate Solr Guide - Aeologic Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/Solr-Client-APIs.png\",\"datePublished\":\"2020-02-14T08:13:48+00:00\",\"dateModified\":\"2020-03-18T08:11:29+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#primaryimage\",\"url\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/Solr-Client-APIs.png\",\"contentUrl\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/Solr-Client-APIs.png\",\"width\":1080,\"height\":622},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.aeologic.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Solr Client API&#8217;s &#8211; Ultimate Solr Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#website\",\"url\":\"https:\/\/www.aeologic.com\/blog\/\",\"name\":\"Aeologic Blog\",\"description\":\"Aeologic\",\"publisher\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.aeologic.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#organization\",\"name\":\"AeoLogic Technologies\",\"url\":\"https:\/\/www.aeologic.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2022\/05\/new-logo-aeo.jpg\",\"contentUrl\":\"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2022\/05\/new-logo-aeo.jpg\",\"width\":385,\"height\":162,\"caption\":\"AeoLogic Technologies\"},\"image\":{\"@id\":\"https:\/\/www.aeologic.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/AeoLogicTech\/\",\"https:\/\/x.com\/aeologictech\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/13549984ba8e5f441cc733ed20d7daa4\",\"name\":\"Manoj Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/24ce77602da5eb5715d74a95733f6c7548e2af73f5a493f9bc0bf55f611d025e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/24ce77602da5eb5715d74a95733f6c7548e2af73f5a493f9bc0bf55f611d025e?s=96&d=mm&r=g\",\"caption\":\"Manoj Kumar\"},\"description\":\"Manoj Kumar is a seasoned Digital Marketing Manager and passionate Tech Blogger with deep expertise in SEO, AI trends, and emerging digital technologies. He writes about innovative solutions that drive growth and transformation across industry. Featured on - YOURSTORY | TECHSLING | ELEARNINGINDUSTRY | DATASCIENCECENTRAL | TIMESOFINDIA | MEDIUM | DATAFLOQ\",\"sameAs\":[\"https:\/\/www.aeologic.com\/\",\"https:\/\/www.linkedin.com\/in\/manoj-kumar-rajput\/\"],\"url\":\"https:\/\/www.aeologic.com\/blog\/author\/manoj\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Solr Client API's - Ultimate Solr Guide - Aeologic Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/","og_locale":"en_US","og_type":"article","og_title":"Solr Client API's - Ultimate Solr Guide - Aeologic Blog","og_description":"Hello Everyone! Today we will discuss another important aspect in solr which is widely used in enterprise-grade applications harnessing the power of solr. In most scenarios, we need to interact with data types of different types and from different sources. Solr provides with multiple client Api&#8217;s to deal with this type of scenario and do much more. Introduction to Client APIs At its heart, Solr is a Web application, but because it is built on open protocols, any type of client application can use Solr. HTTP is the fundamental protocol used between client applications and Solr. The client makes a request and Solr does some work and provides a response. Clients use requests to ask Solr to do things like performing queries or index documents. Client applications can reach Solr by creating HTTP requests and parsing the HTTP responses. Client APIs encapsulate much of the work of sending requests and parsing responses, which makes it much easier to write client applications. Clients use Solr\u2019s five fundamental operations to work with Solr. The operations are query, index, delete, commit, and optimize. Queries are executed by creating a URL that contains all the query parameters. Solr examines the request URL, performs the query, and returns the results. The other operations are similar, although in certain cases the HTTP request is a POST operation and contains information beyond whatever is included in the request URL. An index operation, for example, may contain a document in the body of the request. Choosing an Output Format Many programming environments are able to send HTTP requests and retrieve responses. Parsing the responses is a slightly more thorny problem. Fortunately, Solr makes it easy to choose an output format that will be easy to handle on the client side. Specify a response format using the\u00a0wt parameter in a query. Most client APIs hide this detail for you, so for many types of client applications, you won\u2019t ever have to specify a\u00a0wt\u00a0parameter. In JavaScript, however, the interface to Solr is a little closer to the metal, so you will need to add this parameter yourself. Client API Lineup As of now, solr has follwoing client API&#8217;s in provision: Name Environment URL SolRuby Ruby https:\/\/github.com\/rsolr\/rsolr DelSolr Ruby https:\/\/github.com\/avvo\/delsolr acts_as_solr Rails http:\/\/acts-as-solr.rubyforge.org\/,\u00a0http:\/\/rubyforge.org\/projects\/background-solr\/ Flare Rails http:\/\/wiki.apache.org\/solr\/Flare SolPHP PHP http:\/\/wiki.apache.org\/solr\/SolPHP SolrJ Java http:\/\/wiki.apache.org\/solr\/SolJava Python API Python http:\/\/wiki.apache.org\/solr\/SolPython PySolr Python http:\/\/code.google.com\/p\/pysolr\/ SolPerl Perl http:\/\/wiki.apache.org\/solr\/SolPerl Solr.pm Perl http:\/\/search.cpan.org\/~garafola\/Solr-0.03\/lib\/Solr.pm SolrForrest Forrest\/Cocoon http:\/\/wiki.apache.org\/solr\/SolrForrest SolrSharp C# http:\/\/www.codeplex.com\/solrsharp SolColdfusion ColdFusion http:\/\/solcoldfusion.riaforge.org\/ SolrNet .NET https:\/\/github.com\/mausch\/SolrNet AJAX Solr AJAX http:\/\/github.com\/evolvingweb\/ajax-solr\/wiki Using JavaScript Using Solr from JavaScript clients is so straightforward that it deserves a special mention. In fact, it is so straightforward that there is no client API. You don\u2019t need to install any packages or configure anything. HTTP requests can be sent to Solr using the standard\u00a0XMLHttpRequest\u00a0mechanism. By default, Solr sends Javascript Object Notation(JSON) responses, which are easily interpreted in JavaScript. You don\u2019t need to add anything to the request URL to have responses sent as JSON. Using SolrJ Building and Running SolrJ Applications The SolrJ API ships with Solr, so you do not have to download or install anything else. But you will need to configure your build to include SolrJ and its dependencies. Common Build Systems Most mainstream build systems greatly simplify dependency management, making it easy to add SolrJ to your project. For projects built with Ant (using\u00a0Ivy), place the following in your\u00a0ivy.xml: For projects built with Maven, place the following in your\u00a0pom.xml For projects built with Gradle, place the following in your\u00a0build.gradle: Adding SolrJ to the Classpath Manually If you are not using one of the above build system, it\u2019s still easy to add SolrJ to your build. At build time, all that is required is the SolrJ jar itself:\u00a0solr-solrj-7.4.0.jar. To compile code manually that uses SolrJ, use a\u00a0javac\u00a0command similar to: At runtime, you need a few of SolrJ\u2019s dependencies, in addition to SolrJ itself. For convenience, these dependencies are made available in the\u00a0dist\/solrj-lib\u00a0directory. Run your project with a classpath like: Querying in SolrJ SolrClient\u00a0has a number of\u00a0query()\u00a0methods for fetching results from Solr. Each of these methods takes in a\u00a0SolrParams,an object encapsulating arbitrary query-parameters. And each method outputs a\u00a0QueryResponse, a wrapper which can be used to access the result documents and other related metadata. The following snippet uses a SolrClient to query Solr\u2019s &#8220;techproducts&#8221; example collection, and iterate over the results. SolrParams\u00a0has a\u00a0SolrQuery\u00a0subclass, which provides some convenience methods that greatly simplifies query creation. The following snippet shows how the query from the previous example can be built using some of the convenience methods in\u00a0SolrQuery: Indexing in SolrJ Indexing is also simple using SolrJ. Users build the documents they want to index as instances of\u00a0SolrInputDocument, and provide them as arguments to one of the\u00a0add()\u00a0methods on\u00a0SolrClient. The following example shows how to use SolrJ to add a document to Solr\u2019s &#8220;techproducts&#8221; example collection: So , this is it about solr client API&#8217;s. We will be back with another post very soon.10 Solr Client API&#8217;s","og_url":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/","og_site_name":"Aeologic Blog","article_publisher":"https:\/\/www.facebook.com\/AeoLogicTech\/","article_published_time":"2020-02-14T08:13:48+00:00","article_modified_time":"2020-03-18T08:11:29+00:00","og_image":[{"width":1080,"height":622,"url":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/Solr-Client-APIs.png","type":"image\/png"}],"author":"Manoj Kumar","twitter_card":"summary_large_image","twitter_creator":"@aeologictech","twitter_site":"@aeologictech","twitter_misc":{"Written by":"Manoj Kumar","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#article","isPartOf":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/"},"author":{"name":"Manoj Kumar","@id":"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/13549984ba8e5f441cc733ed20d7daa4"},"headline":"Solr Client API&#8217;s &#8211; Ultimate Solr Guide","datePublished":"2020-02-14T08:13:48+00:00","dateModified":"2020-03-18T08:11:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/"},"wordCount":925,"publisher":{"@id":"https:\/\/www.aeologic.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#primaryimage"},"thumbnailUrl":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/Solr-Client-APIs.png","keywords":["client api","solr","solr client apis","solrj"],"articleSection":["Solr"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/","url":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/","name":"Solr Client API's - Ultimate Solr Guide - Aeologic Blog","isPartOf":{"@id":"https:\/\/www.aeologic.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#primaryimage"},"image":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#primaryimage"},"thumbnailUrl":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/Solr-Client-APIs.png","datePublished":"2020-02-14T08:13:48+00:00","dateModified":"2020-03-18T08:11:29+00:00","breadcrumb":{"@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#primaryimage","url":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/Solr-Client-APIs.png","contentUrl":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/02\/Solr-Client-APIs.png","width":1080,"height":622},{"@type":"BreadcrumbList","@id":"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide-10-solr-client-apis\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.aeologic.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Solr Client API&#8217;s &#8211; Ultimate Solr Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.aeologic.com\/blog\/#website","url":"https:\/\/www.aeologic.com\/blog\/","name":"Aeologic Blog","description":"Aeologic","publisher":{"@id":"https:\/\/www.aeologic.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.aeologic.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.aeologic.com\/blog\/#organization","name":"AeoLogic Technologies","url":"https:\/\/www.aeologic.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.aeologic.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2022\/05\/new-logo-aeo.jpg","contentUrl":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2022\/05\/new-logo-aeo.jpg","width":385,"height":162,"caption":"AeoLogic Technologies"},"image":{"@id":"https:\/\/www.aeologic.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/AeoLogicTech\/","https:\/\/x.com\/aeologictech"]},{"@type":"Person","@id":"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/13549984ba8e5f441cc733ed20d7daa4","name":"Manoj Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.aeologic.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/24ce77602da5eb5715d74a95733f6c7548e2af73f5a493f9bc0bf55f611d025e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/24ce77602da5eb5715d74a95733f6c7548e2af73f5a493f9bc0bf55f611d025e?s=96&d=mm&r=g","caption":"Manoj Kumar"},"description":"Manoj Kumar is a seasoned Digital Marketing Manager and passionate Tech Blogger with deep expertise in SEO, AI trends, and emerging digital technologies. He writes about innovative solutions that drive growth and transformation across industry. Featured on - YOURSTORY | TECHSLING | ELEARNINGINDUSTRY | DATASCIENCECENTRAL | TIMESOFINDIA | MEDIUM | DATAFLOQ","sameAs":["https:\/\/www.aeologic.com\/","https:\/\/www.linkedin.com\/in\/manoj-kumar-rajput\/"],"url":"https:\/\/www.aeologic.com\/blog\/author\/manoj\/"}]}},"_links":{"self":[{"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/posts\/561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/comments?post=561"}],"version-history":[{"count":0,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/posts\/561\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/media\/574"}],"wp:attachment":[{"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/media?parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/categories?post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aeologic.com\/blog\/wp-json\/wp\/v2\/tags?post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}