DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Databases
  4. Couchbase PHP SDK 2.2.0 — Example With Full Text Search
Content provided by Couchbase logo

Couchbase PHP SDK 2.2.0 — Example With Full Text Search

We have a look at how to use the latest Couchbase PHP SDK via full-text search. Read on to see how it's done!

Sergey Avseyev user avatar by
Sergey Avseyev
·
Jul. 12, 16 · Tutorial
Like (4)
Save
Tweet
Share
3.24K Views

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.

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']);
~ $ 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):

pecl install couchbase-2.2.0

If you encounter any issues, please post directly to the Couchbase forums at https://forums.couchbase.com/c/php-sdk. Additionally, bugs can be reported directly through our issue tracker.


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: