Today I’d like to announce the PHP SDK 2.0.0 GA, which brings a couple of new fetures along with more fixes and improvements. In this blog post I will demonstrate one of them (for a full list of changes refer to the Release Notes).
Full Text Search API
You may have heard about this API previously, but this time lets show it from PHP. We assume you have installed Couchbase 4.5 as a minimum and have setup the enhanced sample bucket beer-sample
with defined Full Text index. More information about configuring index find in Full Text search section of SDK guide.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php //we'll use that Cluster and Bucket for the remainder of the examples $cluster = new CouchbaseCluster('couchbase://localhost'); $bucket = $cluster->openBucket('beer-sample'); //we use a simple form of search: $query = CouchbaseSearchQuery::match('national'); //we fire the search and look at results $result = $bucket->query(new CouchbaseSearchQuery('beerIndex', $query)); printf("score id\n----------------------------\n"); foreach ($result->hits as $row) { printf("%f %s\n", $row->score, $row->id); } printf("----------------------------\n"); printf("total hits: %d\n", $result->metrics['total_hits']); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
~ $ php search.php score id ---------------------------- 0.574057 penn_brewery-penn_marzen 0.542845 penn_brewery-penn_oktoberfest 0.536256 chelsea_brewing_company 0.529263 bluegrass_brewing_company_inc 0.528675 labatt_ontario_breweries-labatt_extra_dry 0.489116 rahr_sons_brewing_company-iron_thistle 0.474812 pabst_brewing_company 0.451381 rogue_ales-dad_s_little_helper 0.447907 pabst_brewing_company-lone_star 0.442591 great_divide_brewing-denver_pale_ale_dpa ---------------------------- total hits: 17 |
Find more examples in Searching from the SDK.
Getting the release
To install this release, use the following command and make sure you have libcouchbase 2.6.1+ installed (more details at Start Using the SDK page):
1 2 |
pecl install couchbase-2.2.0 |
If you encounter any issues, please post directly to the Couchbase forums at https://www.couchbase.com/forums/c/php-sdk/. Additionally, bugs can be reported directly through our issue tracker.