Indextank-php-zend-framework is a project mainly written in PHP, based on the View license.
PHP Zend Framework implementation of the IndexTank hosted real-time search client
This library provides a client for the IndexTank hosted real-time search API. The library defines methods to manage indexes (create and delete them), operate on them (add and delete documents, functions, etc), perform searches, etc.
IndexTank requires an API account for usage. You can get one by signing up for free at www.indextank.com.
We connect to IndexTank using our private URL. The private URL is displayed on your account dashboard when logged into IndexTank. Once connected, a new index is created on the server to store our list of books. We then add to books as documents to the index, ready to be searched. The books include three distinct fields, text
(the standard field to be searched), author
and title
which will will later retrieve for listing.
<?
$client = new IndexTank_Client('PRIVATE_URL');
$index = $client->createIndex('books');
$index->addDocument('book1', array(
'title' => 'Little Red Riding Hood',
'author' => 'Folktale',
'text' => 'A famous fairy tale about a young girl and a Big Bad Wolf'
));
$index->addDocument('book2', array(
'title' => 'Hansel and Gretel',
'author' => 'Brothers Grimm',
'text' => 'Hansel and Gretel are a young brother and sister threatened by a witch'
));
In the second example, we reconnect to IndexTank and retrieve the previously created index. We then run a search query on the index, looping through the results printing them. Note that the search is instructed to retrieve all three fields from the index rather than just the default text
field.
<?
$client = new IndexTank_Client('PRIVATE_URL');
$index = $client->getIndex('books');
$results = $index->search('fairy tale');
foreach ($results as $result) {
echo '<a href="/books/' . $result['docid'] . '">' . $result['snippets']['text'] . '</a><br>';
}
echo '<br>';
$results = $index->search('big wolf OR witch', array('text', 'title', 'author'));
foreach ($results as $result) {
echo '<a href="/books/' . $result['docid'] . '">' . $result['fields']['title'] . '</a><br>';
echo '<small><em>' . $result['fields']['author'] . '</em></small><br>';
echo $result['snippets']['text'] . '<br>';
echo '<br>';
}
...
Instead of passing the private IndexTank URL to the constructor every time, you can also configure the library globally as an application resource in your application.ini
.
application.ini
application.ini
; Include IndexTank resource in plugin paths
pluginPaths.IndexTank_Application_Resource = "IndexTank/Application/Resource"
; IndexTank Config
resources.IndexTank.private_url = "http://:[email protected]"
The IndexTank client can now be constructed without passing the private URL every time
<?
$client = new IndexTank_Client();
$index = $client->getIndex('books');
$index->deleteDocument('book1');
IndexTank/
into your include pathgit checkout -b my_changes
)git commit -am "Added Beer Goggle API"
)git push origin my_changes
)Copyright © 2011 Helpdesk. See LICENSE for details.