Skip to content

Instantly share code, notes, and snippets.

@ninetwentyfour
Created May 24, 2011 01:03
Show Gist options
  • Save ninetwentyfour/987971 to your computer and use it in GitHub Desktop.
Save ninetwentyfour/987971 to your computer and use it in GitHub Desktop.
Functions to interact with IndexTank
<?php
function createIndextankClient(){
App::import('Vendor', 'indextank_client');
$API_URL = 'YOUR API URL HERE';
$client = new ApiClient($API_URL);
return $client;
}
function addIndextank($indexType,$id,$data){
//send project to indextank
$client = $this->createIndextankClient();
$index = $client->get_index($indexType);
$doc_id = $id;
$index->add_document($doc_id, $data);
}
function deleteIndextank($indexType,$id){
//delete indextank document
$client = $this->createIndextankClient();
$index = $client->get_index($indexType);
$index->delete_document($id);
}
function searchIndextank($indexType,$query){
//search indextank
$client = $this->createIndextankClient();
$index = $client->get_index($indexType);
$index->add_function(2, "relevance");
$res = $index->search($query);
return $res;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment