Weekly Report 5 Gsoc @ Moodle

Week 5(05 july – 12 july)

Task :- Writing the Methods that talks between Solr’s instance & SolrPhpClient library.

 The task is about writing a PHP File that takes the Solr parameter’s and perform the indexing, deletion of existing index(s) and optimize the index.

File Ajaxcalls.php takes the parameters from YUI module.js file and respond back with the proper json response.

Code Snippets :-
try {
require_once("SolrPhpClient/Apache/Solr/HttpTransport/Curl.php");
$httpTransport = new Apache_Solr_HttpTransport_Curl();       // Create the HttpApacheSolr object
$this->_solr = new Apache_Solr_Service($this->_solrHost, $this->_solrPort, $this->_solrPath, $httpTransport);   // Create the Solr instance
}

catch ( Exception $e ) {
$this->_lastErrorCode = $e->getCode();                              // if not succeed throw the error with
$this->_lastErrorMessage = $e->getMessage();
return false;
}
The deletion can be performed one by one(by passing the id of particular course id) or all at once.

Deletion by passing document id(if a particular course is removed)

Code Snippets:-
       public function deleteById( $doc_id ) {
try {
$this->_solr->deleteById( $doc_id );
$this->_solr->commit();
} catch ( Exception $e ) {
echo $e->getMessage();
}
}

Delete all at once:-
public function deleteAll($optimize = false) {
try {
$this->_solr->deleteByQuery('*:*');
if (!$this->commit())

return false;
if ($optimize)

return $this->optimize();
return true;
} catch ( Exception $e ) {
$this->_lastErrorCode = $e->getCode();
$this->_lastErrorMessage = $e->getMessage();
return false;
}
}
Optimizing the indexes:-

Code Snippets:-
try {
$this->_solr->optimize();
return true;
} catch ( Exception $e ) {
$this->_lastErrorCode = $e->getCode();
$this->_lastErrorMessage = $e->getMessage();
return false;
}

What’s Next week:-

1. Rendering the results on the search page by overriding the existing methods.

2. Writing the README about how to install solr & how to configure.

3. Write the Install/uninstall/Upgrade script of admin tool.

4. Optimize the code & prepare the documentation.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s