Created
May 24, 2011 01:03
-
-
Save ninetwentyfour/987971 to your computer and use it in GitHub Desktop.
Functions to interact with IndexTank
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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