Skip to content

Instantly share code, notes, and snippets.

@arunchinnachamy
Created May 8, 2013 19:18
Show Gist options
  • Save arunchinnachamy/5542892 to your computer and use it in GitHub Desktop.
Save arunchinnachamy/5542892 to your computer and use it in GitHub Desktop.
This file shows how to consume a SOLR API in your PHP script as a JSON output. The script is easy and less than half a dozen code lines. You can find example and tutorial at SOLR Search in PHP tutorial.
<?php
//replace with your query URL
$url = "http://127.0.0.1:8080/solr/core1/select/?q=*%3A*&start=0&rows=10&wt=json";
//Executes the URL and saves the content (json) in the variable.
$content = file_get_contents($url);
if($content) {
$result = json_decode($content,true);
//prints the content of array on the page. Instead perform the operation you ae interested.
var_dump($result);
}
?>
@arunchinnachamy
Copy link
Author

The tutorial about how to use PHP to connect and search in SOLR can be found at SOLR-PHP Search Tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment